Skip to main content

nautilus_execution/matching_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
16/// Configuration for `OrderMatchingEngine` instances.
17#[derive(Debug, Clone)]
18pub struct OrderMatchingEngineConfig {
19    pub bar_execution: bool,
20    pub bar_adaptive_high_low_ordering: bool,
21    pub trade_execution: bool,
22    pub liquidity_consumption: bool,
23    pub reject_stop_orders: bool,
24    pub support_gtd_orders: bool,
25    pub support_contingent_orders: bool,
26    pub use_position_ids: bool,
27    pub use_random_ids: bool,
28    pub use_reduce_only: bool,
29    pub use_market_order_acks: bool,
30    pub queue_position: bool,
31    pub price_protection_points: Option<u32>,
32}
33
34impl OrderMatchingEngineConfig {
35    /// Creates a new default [`OrderMatchingEngineConfig`] instance.
36    #[must_use]
37    #[allow(clippy::too_many_arguments)]
38    pub const fn new(
39        bar_execution: bool,
40        bar_adaptive_high_low_ordering: bool,
41        trade_execution: bool,
42        liquidity_consumption: bool,
43        reject_stop_orders: bool,
44        support_gtd_orders: bool,
45        support_contingent_orders: bool,
46        use_position_ids: bool,
47        use_random_ids: bool,
48        use_reduce_only: bool,
49        use_market_order_acks: bool,
50    ) -> Self {
51        Self {
52            bar_execution,
53            bar_adaptive_high_low_ordering,
54            trade_execution,
55            liquidity_consumption,
56            reject_stop_orders,
57            support_gtd_orders,
58            support_contingent_orders,
59            use_position_ids,
60            use_random_ids,
61            use_reduce_only,
62            use_market_order_acks,
63            queue_position: false,
64            price_protection_points: None,
65        }
66    }
67
68    /// Sets the price protection points for the matching engine.
69    #[must_use]
70    pub const fn with_price_protection_points(
71        mut self,
72        price_protection_points: Option<u32>,
73    ) -> Self {
74        self.price_protection_points = price_protection_points;
75        self
76    }
77}
78
79#[allow(clippy::derivable_impls)]
80impl Default for OrderMatchingEngineConfig {
81    /// Creates a new default [`OrderMatchingEngineConfig`] instance.
82    fn default() -> Self {
83        Self {
84            bar_execution: false,
85            bar_adaptive_high_low_ordering: false,
86            trade_execution: true,
87            liquidity_consumption: false,
88            reject_stop_orders: false,
89            support_gtd_orders: false,
90            support_contingent_orders: false,
91            use_position_ids: false,
92            use_random_ids: false,
93            use_reduce_only: false,
94            use_market_order_acks: false,
95            queue_position: false,
96            price_protection_points: None,
97        }
98    }
99}