nautilus_portfolio/config.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3// https://nautechsystems.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use serde::{Deserialize, Serialize};
17
18/// Configuration for `Portfolio` instances.
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct PortfolioConfig {
21 // The type of prices used for portfolio calculations, such as unrealized PnLs.
22 // If False (default), uses quote prices if available; otherwise, last trade prices
23 // (or falls back to bar prices if `bar_updates` is True).
24 // If True, uses mark prices.
25 #[serde(default)]
26 pub use_mark_prices: bool,
27 // The type of exchange rates used for portfolio calculations.
28 // If False (default), uses quote prices.
29 // If True, uses mark prices.
30 #[serde(default)]
31 pub use_mark_xrates: bool,
32 /// If external bars should be considered for updating unrealized pnls.
33 #[serde(default = "default_true")]
34 pub bar_updates: bool,
35 /// If calculations should be converted into each account's base currency.
36 /// This setting is only effective for accounts with a specified base currency.
37 #[serde(default = "default_true")]
38 pub convert_to_account_base_currency: bool,
39 /// If debug mode is active (will provide extra debug logging).
40 #[serde(default)]
41 pub debug: bool,
42}
43
44const fn default_true() -> bool {
45 true
46}
47
48impl Default for PortfolioConfig {
49 fn default() -> Self {
50 Self {
51 use_mark_prices: false,
52 use_mark_xrates: false,
53 bar_updates: true,
54 convert_to_account_base_currency: true,
55 debug: false,
56 }
57 }
58}