nautilus_model/orders/
default.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Posei Systems Pty Ltd. All rights reserved.
3//  https://poseitrader.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::{UUID4, UnixNanos};
17use rust_decimal_macros::dec;
18
19use super::{
20    limit::LimitOrder, limit_if_touched::LimitIfTouchedOrder, market::MarketOrder,
21    market_if_touched::MarketIfTouchedOrder, market_to_limit::MarketToLimitOrder,
22    stop_limit::StopLimitOrder, stop_market::StopMarketOrder,
23    trailing_stop_limit::TrailingStopLimitOrder, trailing_stop_market::TrailingStopMarketOrder,
24};
25use crate::{
26    enums::{OrderSide, TimeInForce, TrailingOffsetType, TriggerType},
27    identifiers::{ClientOrderId, InstrumentId, StrategyId, TraderId},
28    types::{Price, Quantity},
29};
30
31impl Default for LimitOrder {
32    /// Creates a new default [`LimitOrder`] instance for testing.
33    fn default() -> Self {
34        Self::new(
35            TraderId::default(),
36            StrategyId::default(),
37            InstrumentId::default(),
38            ClientOrderId::default(),
39            OrderSide::Buy,
40            Quantity::from(100_000),
41            Price::from("1.00000"),
42            TimeInForce::Gtc,
43            None,
44            false,
45            false,
46            false,
47            None,
48            None,
49            None,
50            None,
51            None,
52            None,
53            None,
54            None,
55            None,
56            None,
57            None,
58            UUID4::default(),
59            UnixNanos::default(),
60        )
61    }
62}
63
64impl Default for LimitIfTouchedOrder {
65    /// Creates a new default [`LimitIfTouchedOrder`] instance for testing.
66    fn default() -> Self {
67        Self::new(
68            TraderId::default(),
69            StrategyId::default(),
70            InstrumentId::default(),
71            ClientOrderId::default(),
72            OrderSide::Buy,
73            Quantity::from(100_000),
74            Price::from("1.00000"),
75            Price::from("1.00000"),
76            TriggerType::BidAsk,
77            TimeInForce::Gtc,
78            None,
79            false,
80            false,
81            false,
82            None,
83            None,
84            None,
85            None,
86            None,
87            None,
88            None,
89            None,
90            None,
91            None,
92            None,
93            UUID4::default(),
94            UnixNanos::default(),
95        )
96    }
97}
98
99impl Default for MarketOrder {
100    /// Creates a new default [`MarketOrder`] instance for testing.
101    fn default() -> Self {
102        Self::new(
103            TraderId::default(),
104            StrategyId::default(),
105            InstrumentId::default(),
106            ClientOrderId::default(),
107            OrderSide::Buy,
108            Quantity::from(100_000),
109            TimeInForce::Day,
110            UUID4::default(),
111            UnixNanos::default(),
112            false,
113            false,
114            None,
115            None,
116            None,
117            None,
118            None,
119            None,
120            None,
121            None,
122        )
123    }
124}
125
126impl Default for MarketIfTouchedOrder {
127    /// Creates a new default [`MarketIfTouchedOrder`] instance for testing.
128    fn default() -> Self {
129        Self::new(
130            TraderId::default(),
131            StrategyId::default(),
132            InstrumentId::default(),
133            ClientOrderId::default(),
134            OrderSide::Buy,
135            Quantity::from(100_000),
136            Price::from("1.00000"),
137            TriggerType::BidAsk,
138            TimeInForce::Gtc,
139            None,
140            false,
141            false,
142            None,
143            None,
144            None,
145            None,
146            None,
147            None,
148            None,
149            None,
150            None,
151            None,
152            UUID4::default(),
153            UnixNanos::default(),
154        )
155    }
156}
157
158impl Default for MarketToLimitOrder {
159    /// Creates a new default [`MarketToLimitOrder`] instance for testing.
160    fn default() -> Self {
161        Self::new(
162            TraderId::default(),
163            StrategyId::default(),
164            InstrumentId::default(),
165            ClientOrderId::default(),
166            OrderSide::Buy,
167            Quantity::from(100_000),
168            TimeInForce::Gtc,
169            None,
170            false,
171            false,
172            false,
173            None,
174            None,
175            None,
176            None,
177            None,
178            None,
179            None,
180            None,
181            None,
182            UUID4::default(),
183            UnixNanos::default(),
184        )
185    }
186}
187
188impl Default for StopLimitOrder {
189    /// Creates a new default [`StopLimitOrder`] instance for testing.
190    fn default() -> Self {
191        Self::new(
192            TraderId::default(),
193            StrategyId::default(),
194            InstrumentId::default(),
195            ClientOrderId::default(),
196            OrderSide::Buy,
197            Quantity::from(100_000),
198            Price::from("1.00000"),
199            Price::from("1.00000"),
200            TriggerType::BidAsk,
201            TimeInForce::Gtc,
202            None,
203            false,
204            false,
205            false,
206            None,
207            None,
208            None,
209            None,
210            None,
211            None,
212            None,
213            None,
214            None,
215            None,
216            None,
217            UUID4::default(),
218            UnixNanos::default(),
219        )
220    }
221}
222
223impl Default for StopMarketOrder {
224    /// Creates a new default [`StopMarketOrder`] instance for testing.
225    fn default() -> Self {
226        Self::new(
227            TraderId::default(),
228            StrategyId::default(),
229            InstrumentId::default(),
230            ClientOrderId::default(),
231            OrderSide::Buy,
232            Quantity::from(100_000),
233            Price::from("1.00000"),
234            TriggerType::BidAsk,
235            TimeInForce::Gtc,
236            None,
237            false,
238            false,
239            None,
240            None,
241            None,
242            None,
243            None,
244            None,
245            None,
246            None,
247            None,
248            None,
249            None,
250            UUID4::default(),
251            UnixNanos::default(),
252        )
253    }
254}
255
256impl Default for TrailingStopLimitOrder {
257    /// Creates a new default [`TrailingStopLimitOrder`] instance for testing.
258    fn default() -> Self {
259        Self::new(
260            TraderId::default(),
261            StrategyId::default(),
262            InstrumentId::default(),
263            ClientOrderId::default(),
264            OrderSide::Buy,
265            Quantity::from(100_000),
266            Price::from("1.00000"),
267            Price::from("1.00000"),
268            TriggerType::BidAsk,
269            dec!(0.001),
270            dec!(0.001),
271            TrailingOffsetType::Price,
272            TimeInForce::Gtc,
273            None,
274            false,
275            false,
276            false,
277            None,
278            None,
279            None,
280            None,
281            None,
282            None,
283            None,
284            None,
285            None,
286            None,
287            None,
288            UUID4::default(),
289            UnixNanos::default(),
290        )
291    }
292}
293
294impl Default for TrailingStopMarketOrder {
295    /// Creates a new default [`TrailingStopMarketOrder`] instance for testing.
296    fn default() -> Self {
297        Self::new(
298            TraderId::default(),
299            StrategyId::default(),
300            InstrumentId::default(),
301            ClientOrderId::default(),
302            OrderSide::Buy,
303            Quantity::from(100_000),
304            Price::from("1.00000"),
305            TriggerType::BidAsk,
306            dec!(0.001),
307            TrailingOffsetType::Price,
308            TimeInForce::Gtc,
309            None,
310            false,
311            false,
312            None,
313            None,
314            None,
315            None,
316            None,
317            None,
318            None,
319            None,
320            None,
321            None,
322            None,
323            UUID4::default(),
324            UnixNanos::default(),
325        )
326    }
327}