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 nautilus_model::identifiers::ClientId;
17use serde::{Deserialize, Serialize};
18
19/// Configuration for `ExecutionEngine` instances.
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct ExecutionEngineConfig {
22    /// If the cache should be loaded on initialization.
23    #[serde(default = "default_true")]
24    pub load_cache: bool,
25    /// If the execution engine should maintain own/user order books based on commands and events.
26    #[serde(default)]
27    pub manage_own_order_books: bool,
28    /// If order state snapshot lists are persisted to a backing database.
29    /// Snapshots will be taken at every order state update (when events are applied).
30    #[serde(default)]
31    pub snapshot_orders: bool,
32    /// If position state snapshot lists are persisted to a backing database.
33    /// Snapshots will be taken at position opened, changed and closed (when events are applied).
34    #[serde(default)]
35    pub snapshot_positions: bool,
36    /// The interval (seconds) at which additional position state snapshots are persisted.
37    /// If None then no additional snapshots will be taken.
38    #[serde(default)]
39    pub snapshot_positions_interval_secs: Option<f64>,
40    /// The client IDs declared for external stream processing.
41    ///
42    /// The execution engine will not attempt to send trading commands to these
43    /// client IDs, assuming an external process will consume the serialized
44    /// command messages from the bus and handle execution.
45    #[serde(default)]
46    pub external_clients: Option<Vec<ClientId>>,
47    /// If debug mode is active (will provide extra debug logging).
48    #[serde(default)]
49    pub debug: bool,
50}
51
52const fn default_true() -> bool {
53    true
54}
55
56impl Default for ExecutionEngineConfig {
57    fn default() -> Self {
58        Self {
59            load_cache: true,
60            manage_own_order_books: false,
61            snapshot_orders: false,
62            snapshot_positions: false,
63            snapshot_positions_interval_secs: None,
64            external_clients: None,
65            debug: false,
66        }
67    }
68}