Skip to main content

nautilus_model/events/order/
mod.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
16use indexmap::IndexMap;
17use nautilus_core::{UUID4, UnixNanos};
18use rust_decimal::Decimal;
19use ustr::Ustr;
20
21use crate::{
22    enums::{
23        ContingencyType, LiquiditySide, OrderSide, OrderType, TimeInForce, TrailingOffsetType,
24        TriggerType,
25    },
26    identifiers::{
27        AccountId, ClientOrderId, ExecAlgorithmId, InstrumentId, OrderListId, PositionId,
28        StrategyId, TradeId, TraderId, VenueOrderId,
29    },
30    types::{Currency, Money, Price, Quantity},
31};
32
33pub mod accepted;
34pub mod accepted_batch;
35pub mod any;
36pub mod cancel_rejected;
37pub mod canceled;
38pub mod canceled_batch;
39pub mod denied;
40pub mod denied_reason;
41pub mod emulated;
42pub mod expired;
43pub mod fill_voided;
44pub mod filled;
45pub mod initialized;
46pub mod modify_rejected;
47pub mod pending_cancel;
48pub mod pending_update;
49pub mod rejected;
50pub mod released;
51pub mod snapshot;
52pub mod submitted;
53pub mod submitted_batch;
54pub mod triggered;
55pub mod updated;
56
57#[cfg(any(test, feature = "test-support"))]
58pub mod spec;
59#[cfg(any(test, feature = "test-support"))]
60pub mod stubs;
61
62/// Represents a type of [`OrderEvent`].
63#[derive(Debug, PartialEq, Eq)]
64pub enum OrderEventType {
65    Initialized,
66    Denied,
67    Emulated,
68    Released,
69    Submitted,
70    Accepted,
71    Rejected,
72    Canceled,
73    Expired,
74    Triggered,
75    PendingUpdate,
76    PendingCancel,
77    ModifyRejected,
78    CancelRejected,
79    Updated,
80    PartiallyFilled,
81    Filled,
82    FillVoided,
83}
84
85pub trait OrderEvent: 'static + Send {
86    fn id(&self) -> UUID4;
87    fn type_name(&self) -> &'static str;
88    fn order_type(&self) -> Option<OrderType>;
89    fn order_side(&self) -> Option<OrderSide>;
90    fn trader_id(&self) -> TraderId;
91    fn strategy_id(&self) -> StrategyId;
92    fn instrument_id(&self) -> InstrumentId;
93    fn trade_id(&self) -> Option<TradeId>;
94    fn currency(&self) -> Option<Currency>;
95    fn client_order_id(&self) -> ClientOrderId;
96    fn reason(&self) -> Option<Ustr>;
97    fn quantity(&self) -> Option<Quantity>;
98    fn time_in_force(&self) -> Option<TimeInForce>;
99    fn liquidity_side(&self) -> Option<LiquiditySide>;
100    fn post_only(&self) -> Option<bool>;
101    fn reduce_only(&self) -> Option<bool>;
102    fn quote_quantity(&self) -> Option<bool>;
103    fn reconciliation(&self) -> bool;
104    fn price(&self) -> Option<Price>;
105    fn last_px(&self) -> Option<Price>;
106    fn last_qty(&self) -> Option<Quantity>;
107    fn activation_price(&self) -> Option<Price>;
108    fn trigger_price(&self) -> Option<Price>;
109    fn trigger_type(&self) -> Option<TriggerType>;
110    fn limit_offset(&self) -> Option<Decimal>;
111    fn trailing_offset(&self) -> Option<Decimal>;
112    fn trailing_offset_type(&self) -> Option<TrailingOffsetType>;
113    fn expire_time(&self) -> Option<UnixNanos>;
114    fn display_qty(&self) -> Option<Quantity>;
115    fn emulation_trigger(&self) -> Option<TriggerType>;
116    fn trigger_instrument_id(&self) -> Option<InstrumentId>;
117    fn contingency_type(&self) -> Option<ContingencyType>;
118    fn order_list_id(&self) -> Option<OrderListId>;
119    fn linked_order_ids(&self) -> Option<Vec<ClientOrderId>>;
120    fn parent_order_id(&self) -> Option<ClientOrderId>;
121    fn exec_algorithm_id(&self) -> Option<ExecAlgorithmId>;
122    fn exec_algorithm_params(&self) -> Option<IndexMap<Ustr, Ustr>> {
123        None
124    }
125    fn exec_spawn_id(&self) -> Option<ClientOrderId>;
126    fn tags(&self) -> Option<Vec<Ustr>> {
127        None
128    }
129    fn venue_order_id(&self) -> Option<VenueOrderId>;
130    fn account_id(&self) -> Option<AccountId>;
131    fn position_id(&self) -> Option<PositionId>;
132    fn commission(&self) -> Option<Money>;
133    fn ts_event(&self) -> UnixNanos;
134    fn ts_init(&self) -> UnixNanos;
135}