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 the execution engine should maintain own/user order books based on commands and events.
25    #[serde(default)]
26    pub manage_own_order_books: bool,
27    /// If order state snapshot lists are persisted to a backing database.
28    /// Snapshots will be taken at every order state update (when events are applied).
29    #[serde(default)]
30    pub snapshot_orders: bool,
31    /// If position state snapshot lists are persisted to a backing database.
32    /// Snapshots will be taken at position opened, changed and closed (when events are applied).
33    #[serde(default)]
34    pub snapshot_positions: bool,
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    /// 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 ExecutionEngineConfig {
49    fn default() -> Self {
50        Self {
51            load_cache: true,
52            manage_own_order_books: false,
53            snapshot_orders: false,
54            snapshot_positions: false,
55            snapshot_positions_interval_secs: None,
56            debug: false,
57        }
58    }
59}