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