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    /// If order state snapshot lists are persisted to a backing database.
25    /// Snapshots will be taken at every order state update (when events are applied).
26    #[serde(default)]
27    pub snapshot_orders: bool,
28    /// If position state snapshot lists are persisted to a backing database.
29    /// Snapshots will be taken at position opened, changed and closed (when events are applied).
30    #[serde(default)]
31    pub snapshot_positions: bool,
32    /// The interval (seconds) at which additional position state snapshots are persisted.
33    /// If None then no additional snapshots will be taken.
34    #[serde(default)]
35    pub snapshot_positions_interval_secs: Option<f64>,
36    /// If debug mode is active (will provide extra debug logging).
37    #[serde(default)]
38    pub debug: bool,
39}
40
41const fn default_true() -> bool {
42    true
43}
44
45impl Default for ExecutionEngineConfig {
46    fn default() -> Self {
47        Self {
48            load_cache: true,
49            snapshot_orders: false,
50            snapshot_positions: false,
51            snapshot_positions_interval_secs: None,
52            debug: false,
53        }
54    }
55}