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