nautilus_execution/engine/
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 `ExecutionEngine` instances.
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct ExecutionEngineConfig {
21    /// If the cache should be loaded on initialization
22    #[serde(default = "default_true")]
23    pub load_cache: bool,
24
25    /// If order state snapshot lists are persisted to a backing database.
26    /// Snapshots will be taken at every order state update (when events are applied).
27    #[serde(default)]
28    pub snapshot_orders: bool,
29
30    /// If position state snapshot lists are persisted to a backing database.
31    /// Snapshots will be taken at position opened, changed and closed (when events are applied).
32    #[serde(default)]
33    pub snapshot_positions: bool,
34
35    /// The interval (seconds) at which additional position state snapshots are persisted
36    /// If None then no additional snapshots will be taken
37    #[serde(default)]
38    pub snapshot_positions_interval_secs: Option<f64>,
39
40    /// If debug mode is active (will provide extra debug logging)
41    #[serde(default)]
42    pub debug: bool,
43}
44
45const fn default_true() -> bool {
46    true
47}
48
49impl Default for ExecutionEngineConfig {
50    fn default() -> Self {
51        Self {
52            load_cache: true,
53            snapshot_orders: false,
54            snapshot_positions: false,
55            snapshot_positions_interval_secs: None,
56            debug: false,
57        }
58    }
59}