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