nautilus_portfolio/config.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2026 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 nautilus_core::serialization::default_true;
17use serde::{Deserialize, Serialize};
18
19/// Configuration for `Portfolio` instances.
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct PortfolioConfig {
22 /// The type of prices used for portfolio calculations, such as unrealized PnLs.
23 /// If false (default), uses quote prices if available; otherwise, last trade prices
24 /// (or falls back to bar prices if `bar_updates` is true).
25 /// If true, uses mark prices.
26 #[serde(default)]
27 pub use_mark_prices: bool,
28 /// The type of exchange rates used for portfolio calculations.
29 /// If false (default), uses quote prices.
30 /// If true, uses mark prices.
31 #[serde(default)]
32 pub use_mark_xrates: bool,
33 /// If external bars should be considered for updating unrealized PnLs.
34 #[serde(default = "default_true")]
35 pub bar_updates: bool,
36 /// If calculations should be converted into each account's base currency.
37 /// This setting is only effective for accounts with a specified base currency.
38 #[serde(default = "default_true")]
39 pub convert_to_account_base_currency: bool,
40 /// The minimum interval (milliseconds) between logging account state events for the same account.
41 /// When set, account state updates will only be logged if this much time has passed since the last log.
42 /// Useful for HFT deployments to prevent excessive logging when account states change rapidly.
43 #[serde(default)]
44 pub min_account_state_logging_interval_ms: Option<u64>,
45 /// If debug mode is active (will provide extra debug logging).
46 #[serde(default)]
47 pub debug: bool,
48}
49
50impl Default for PortfolioConfig {
51 fn default() -> Self {
52 Self {
53 use_mark_prices: false,
54 use_mark_xrates: false,
55 bar_updates: true,
56 convert_to_account_base_currency: true,
57 min_account_state_logging_interval_ms: None,
58 debug: false,
59 }
60 }
61}