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    /// If quote-denominated order quantities should be converted to base units before submission.
41    #[serde(default = "default_true")]
42    pub convert_quote_qty_to_base: bool,
43    /// The client IDs declared for external stream processing.
44    ///
45    /// The execution engine will not attempt to send trading commands to these
46    /// client IDs, assuming an external process will consume the serialized
47    /// command messages from the bus and handle execution.
48    #[serde(default)]
49    pub external_clients: Option<Vec<ClientId>>,
50    /// If debug mode is active (will provide extra debug logging).
51    #[serde(default)]
52    pub debug: bool,
53}
54
55const fn default_true() -> bool {
56    true
57}
58
59impl Default for ExecutionEngineConfig {
60    fn default() -> Self {
61        Self {
62            load_cache: true,
63            manage_own_order_books: false,
64            snapshot_orders: false,
65            snapshot_positions: false,
66            snapshot_positions_interval_secs: None,
67            convert_quote_qty_to_base: true,
68            external_clients: None,
69            debug: false,
70        }
71    }
72}