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