nautilus_backtest/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}
27
28impl OrderMatchingEngineConfig {
29 /// Creates a new default [`OrderMatchingEngineConfig`] instance.
30 #[must_use]
31 pub const fn new(
32 bar_execution: bool,
33 reject_stop_orders: bool,
34 support_gtd_orders: bool,
35 support_contingent_orders: bool,
36 use_position_ids: bool,
37 use_random_ids: bool,
38 use_reduce_only: bool,
39 ) -> Self {
40 Self {
41 bar_execution,
42 reject_stop_orders,
43 support_gtd_orders,
44 support_contingent_orders,
45 use_position_ids,
46 use_random_ids,
47 use_reduce_only,
48 }
49 }
50}
51
52#[allow(clippy::derivable_impls)]
53impl Default for OrderMatchingEngineConfig {
54 /// Creates a new default [`OrderMatchingEngineConfig`] instance.
55 fn default() -> Self {
56 Self {
57 bar_execution: false,
58 reject_stop_orders: false,
59 support_gtd_orders: false,
60 support_contingent_orders: false,
61 use_position_ids: false,
62 use_random_ids: false,
63 use_reduce_only: false,
64 }
65 }
66}