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