nautilus_execution/engine/
config.rs

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