1use std::{str::FromStr, sync::OnceLock};
19
20use ahash::AHashSet;
21use serde::{Deserialize, Deserializer, Serialize, Serializer};
22use strum::{AsRefStr, Display, EnumIter, EnumString, FromRepr};
23
24use crate::enum_strum_serde;
25
26pub trait FromU8 {
28 fn from_u8(value: u8) -> Option<Self>
32 where
33 Self: Sized;
34}
35
36pub trait FromU16 {
38 fn from_u16(value: u16) -> Option<Self>
42 where
43 Self: Sized;
44}
45
46#[repr(C)]
48#[derive(
49 Copy,
50 Clone,
51 Debug,
52 Display,
53 Hash,
54 PartialEq,
55 Eq,
56 PartialOrd,
57 Ord,
58 AsRefStr,
59 FromRepr,
60 EnumIter,
61 EnumString,
62)]
63#[strum(ascii_case_insensitive)]
64#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
65#[cfg_attr(
66 feature = "python",
67 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
68)]
69pub enum AccountType {
70 Cash = 1,
72 Margin = 2,
74 Betting = 3,
76}
77
78#[repr(C)]
80#[derive(
81 Copy,
82 Clone,
83 Debug,
84 Display,
85 Hash,
86 PartialEq,
87 Eq,
88 PartialOrd,
89 Ord,
90 AsRefStr,
91 FromRepr,
92 EnumIter,
93 EnumString,
94)]
95#[strum(ascii_case_insensitive)]
96#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
97#[cfg_attr(
98 feature = "python",
99 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
100)]
101pub enum AggregationSource {
102 External = 1,
104 Internal = 2,
106}
107
108#[repr(C)]
110#[derive(
111 Copy,
112 Clone,
113 Debug,
114 Default,
115 Display,
116 Hash,
117 PartialEq,
118 Eq,
119 PartialOrd,
120 Ord,
121 AsRefStr,
122 FromRepr,
123 EnumIter,
124 EnumString,
125)]
126#[strum(ascii_case_insensitive)]
127#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
128#[cfg_attr(
129 feature = "python",
130 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
131)]
132pub enum AggressorSide {
133 #[default]
135 NoAggressor = 0,
136 Buyer = 1,
138 Seller = 2,
140}
141
142impl FromU8 for AggressorSide {
143 fn from_u8(value: u8) -> Option<Self> {
144 match value {
145 0 => Some(Self::NoAggressor),
146 1 => Some(Self::Buyer),
147 2 => Some(Self::Seller),
148 _ => None,
149 }
150 }
151}
152
153#[repr(C)]
155#[derive(
156 Copy,
157 Clone,
158 Debug,
159 Display,
160 Hash,
161 PartialEq,
162 Eq,
163 PartialOrd,
164 Ord,
165 AsRefStr,
166 FromRepr,
167 EnumIter,
168 EnumString,
169)]
170#[strum(ascii_case_insensitive)]
171#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
172#[cfg_attr(
173 feature = "python",
174 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
175)]
176#[allow(non_camel_case_types)]
177pub enum AssetClass {
178 FX = 1,
180 Equity = 2,
182 Commodity = 3,
184 Debt = 4,
186 Index = 5,
188 Cryptocurrency = 6,
190 Alternative = 7,
192}
193
194impl FromU8 for AssetClass {
195 fn from_u8(value: u8) -> Option<Self> {
196 match value {
197 1 => Some(Self::FX),
198 2 => Some(Self::Equity),
199 3 => Some(Self::Commodity),
200 4 => Some(Self::Debt),
201 5 => Some(Self::Index),
202 6 => Some(Self::Cryptocurrency),
203 7 => Some(Self::Alternative),
204 _ => None,
205 }
206 }
207}
208
209#[repr(C)]
211#[derive(
212 Copy,
213 Clone,
214 Debug,
215 Display,
216 Hash,
217 PartialEq,
218 Eq,
219 PartialOrd,
220 Ord,
221 AsRefStr,
222 FromRepr,
223 EnumIter,
224 EnumString,
225)]
226#[strum(ascii_case_insensitive)]
227#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
228#[cfg_attr(
229 feature = "python",
230 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
231)]
232pub enum InstrumentClass {
233 Spot = 1,
235 Swap = 2,
237 Future = 3,
239 FuturesSpread = 4,
241 Forward = 5,
243 Cfd = 6,
245 Bond = 7,
247 Option = 8,
249 OptionSpread = 9,
251 Warrant = 10,
253 SportsBetting = 11,
255 BinaryOption = 12,
258}
259
260#[repr(C)]
262#[derive(
263 Copy,
264 Clone,
265 Debug,
266 Display,
267 Hash,
268 PartialEq,
269 Eq,
270 PartialOrd,
271 Ord,
272 AsRefStr,
273 FromRepr,
274 EnumIter,
275 EnumString,
276)]
277#[strum(ascii_case_insensitive)]
278#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
279#[cfg_attr(
280 feature = "python",
281 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
282)]
283pub enum BarAggregation {
284 Tick = 1,
286 TickImbalance = 2,
288 TickRuns = 3,
290 Volume = 4,
292 VolumeImbalance = 5,
294 VolumeRuns = 6,
296 Value = 7,
298 ValueImbalance = 8,
300 ValueRuns = 9,
302 Millisecond = 10,
304 Second = 11,
306 Minute = 12,
308 Hour = 13,
310 Day = 14,
312 Week = 15,
314 Month = 16,
316 Year = 17,
318 Renko = 18,
320}
321
322#[repr(C)]
324#[derive(
325 Copy,
326 Clone,
327 Debug,
328 Default,
329 Display,
330 Hash,
331 PartialEq,
332 Eq,
333 PartialOrd,
334 Ord,
335 AsRefStr,
336 FromRepr,
337 EnumIter,
338 EnumString,
339)]
340#[strum(ascii_case_insensitive)]
341#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
342#[cfg_attr(
343 feature = "python",
344 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
345)]
346pub enum BarIntervalType {
347 #[default]
349 LeftOpen = 1,
350 RightOpen = 2,
352}
353
354#[repr(C)]
356#[derive(
357 Copy,
358 Clone,
359 Debug,
360 Display,
361 Hash,
362 PartialEq,
363 Eq,
364 PartialOrd,
365 Ord,
366 AsRefStr,
367 FromRepr,
368 EnumIter,
369 EnumString,
370)]
371#[strum(ascii_case_insensitive)]
372#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
373#[cfg_attr(
374 feature = "python",
375 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
376)]
377pub enum BetSide {
378 Back = 1,
380 Lay = 2,
382}
383
384impl BetSide {
385 #[must_use]
387 pub fn opposite(&self) -> Self {
388 match self {
389 Self::Back => Self::Lay,
390 Self::Lay => Self::Back,
391 }
392 }
393}
394
395impl From<OrderSide> for BetSide {
396 fn from(side: OrderSide) -> Self {
402 match side {
403 OrderSide::Buy => BetSide::Back,
404 OrderSide::Sell => BetSide::Lay,
405 OrderSide::NoOrderSide => panic!("Invalid `OrderSide` for `BetSide`, was {side}"),
406 }
407 }
408}
409
410#[repr(C)]
412#[derive(
413 Copy,
414 Clone,
415 Debug,
416 Display,
417 Hash,
418 PartialEq,
419 Eq,
420 PartialOrd,
421 Ord,
422 AsRefStr,
423 FromRepr,
424 EnumIter,
425 EnumString,
426)]
427#[strum(ascii_case_insensitive)]
428#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
429#[cfg_attr(
430 feature = "python",
431 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
432)]
433pub enum BookAction {
434 Add = 1,
436 Update = 2,
438 Delete = 3,
440 Clear = 4,
442}
443
444impl FromU8 for BookAction {
445 fn from_u8(value: u8) -> Option<Self> {
446 match value {
447 1 => Some(Self::Add),
448 2 => Some(Self::Update),
449 3 => Some(Self::Delete),
450 4 => Some(Self::Clear),
451 _ => None,
452 }
453 }
454}
455
456#[repr(C)]
458#[derive(
459 Copy,
460 Clone,
461 Debug,
462 Display,
463 Hash,
464 PartialEq,
465 Eq,
466 PartialOrd,
467 Ord,
468 AsRefStr,
469 FromRepr,
470 EnumIter,
471 EnumString,
472)]
473#[strum(ascii_case_insensitive)]
474#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
475#[allow(non_camel_case_types)]
476#[cfg_attr(
477 feature = "python",
478 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
479)]
480pub enum BookType {
481 L1_MBP = 1,
483 L2_MBP = 2,
485 L3_MBO = 3,
487}
488
489impl FromU8 for BookType {
490 fn from_u8(value: u8) -> Option<Self> {
491 match value {
492 1 => Some(Self::L1_MBP),
493 2 => Some(Self::L2_MBP),
494 3 => Some(Self::L3_MBO),
495 _ => None,
496 }
497 }
498}
499
500#[repr(C)]
504#[derive(
505 Copy,
506 Clone,
507 Debug,
508 Default,
509 Display,
510 Hash,
511 PartialEq,
512 Eq,
513 PartialOrd,
514 Ord,
515 AsRefStr,
516 FromRepr,
517 EnumIter,
518 EnumString,
519)]
520#[strum(ascii_case_insensitive)]
521#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
522#[cfg_attr(
523 feature = "python",
524 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
525)]
526pub enum ContingencyType {
527 #[default]
529 NoContingency = 0,
530 Oco = 1,
532 Oto = 2,
534 Ouo = 3,
536}
537
538#[repr(C)]
540#[derive(
541 Copy,
542 Clone,
543 Debug,
544 Display,
545 Hash,
546 PartialEq,
547 Eq,
548 PartialOrd,
549 Ord,
550 AsRefStr,
551 FromRepr,
552 EnumIter,
553 EnumString,
554)]
555#[strum(ascii_case_insensitive)]
556#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
557#[cfg_attr(
558 feature = "python",
559 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
560)]
561pub enum CurrencyType {
562 Crypto = 1,
564 Fiat = 2,
566 CommodityBacked = 3,
568}
569
570#[repr(C)]
572#[derive(
573 Copy,
574 Clone,
575 Debug,
576 Display,
577 Hash,
578 PartialEq,
579 Eq,
580 PartialOrd,
581 Ord,
582 AsRefStr,
583 FromRepr,
584 EnumIter,
585 EnumString,
586)]
587#[strum(ascii_case_insensitive)]
588#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
589#[cfg_attr(
590 feature = "python",
591 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
592)]
593pub enum InstrumentCloseType {
594 EndOfSession = 1,
596 ContractExpired = 2,
598}
599
600impl FromU8 for InstrumentCloseType {
602 fn from_u8(value: u8) -> Option<Self> {
603 match value {
604 1 => Some(Self::EndOfSession),
605 2 => Some(Self::ContractExpired),
606 _ => None,
607 }
608 }
609}
610
611#[repr(C)]
613#[derive(
614 Copy,
615 Clone,
616 Debug,
617 Display,
618 Hash,
619 PartialEq,
620 Eq,
621 PartialOrd,
622 Ord,
623 AsRefStr,
624 FromRepr,
625 EnumIter,
626 EnumString,
627)]
628#[strum(ascii_case_insensitive)]
629#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
630#[cfg_attr(
631 feature = "python",
632 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
633)]
634#[allow(clippy::enum_variant_names)]
635pub enum LiquiditySide {
636 NoLiquiditySide = 0,
638 Maker = 1,
640 Taker = 2,
642}
643
644#[repr(C)]
646#[derive(
647 Copy,
648 Clone,
649 Debug,
650 Display,
651 Hash,
652 PartialEq,
653 Eq,
654 PartialOrd,
655 Ord,
656 AsRefStr,
657 FromRepr,
658 EnumIter,
659 EnumString,
660)]
661#[strum(ascii_case_insensitive)]
662#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
663#[cfg_attr(
664 feature = "python",
665 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
666)]
667pub enum MarketStatus {
668 Open = 1,
670 Closed = 2,
672 Paused = 3,
674 Suspended = 5,
678 NotAvailable = 6,
680}
681
682#[repr(C)]
684#[derive(
685 Copy,
686 Clone,
687 Debug,
688 Display,
689 Hash,
690 PartialEq,
691 Eq,
692 PartialOrd,
693 Ord,
694 AsRefStr,
695 FromRepr,
696 EnumIter,
697 EnumString,
698)]
699#[strum(ascii_case_insensitive)]
700#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
701#[cfg_attr(
702 feature = "python",
703 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
704)]
705pub enum MarketStatusAction {
706 None = 0,
708 PreOpen = 1,
710 PreCross = 2,
712 Quoting = 3,
714 Cross = 4,
716 Rotation = 5,
718 NewPriceIndication = 6,
720 Trading = 7,
722 Halt = 8,
724 Pause = 9,
726 Suspend = 10,
728 PreClose = 11,
730 Close = 12,
732 PostClose = 13,
734 ShortSellRestrictionChange = 14,
736 NotAvailableForTrading = 15,
738}
739
740impl FromU16 for MarketStatusAction {
742 fn from_u16(value: u16) -> Option<Self> {
743 match value {
744 0 => Some(Self::None),
745 1 => Some(Self::PreOpen),
746 2 => Some(Self::PreCross),
747 3 => Some(Self::Quoting),
748 4 => Some(Self::Cross),
749 5 => Some(Self::Rotation),
750 6 => Some(Self::NewPriceIndication),
751 7 => Some(Self::Trading),
752 8 => Some(Self::Halt),
753 9 => Some(Self::Pause),
754 10 => Some(Self::Suspend),
755 11 => Some(Self::PreClose),
756 12 => Some(Self::Close),
757 13 => Some(Self::PostClose),
758 14 => Some(Self::ShortSellRestrictionChange),
759 15 => Some(Self::NotAvailableForTrading),
760 _ => None,
761 }
762 }
763}
764
765#[repr(C)]
767#[derive(
768 Copy,
769 Clone,
770 Debug,
771 Default,
772 Display,
773 Hash,
774 PartialEq,
775 Eq,
776 PartialOrd,
777 Ord,
778 AsRefStr,
779 FromRepr,
780 EnumIter,
781 EnumString,
782)]
783#[strum(ascii_case_insensitive)]
784#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
785#[cfg_attr(
786 feature = "python",
787 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
788)]
789pub enum OmsType {
790 #[default]
792 Unspecified = 0,
793 Netting = 1,
795 Hedging = 2,
799}
800
801#[repr(C)]
803#[derive(
804 Copy,
805 Clone,
806 Debug,
807 Display,
808 Hash,
809 PartialEq,
810 Eq,
811 PartialOrd,
812 Ord,
813 AsRefStr,
814 FromRepr,
815 EnumIter,
816 EnumString,
817)]
818#[strum(ascii_case_insensitive)]
819#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
820#[cfg_attr(
821 feature = "python",
822 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
823)]
824pub enum OptionKind {
825 Call = 1,
827 Put = 2,
829}
830
831#[repr(C)]
833#[derive(
834 Copy,
835 Clone,
836 Debug,
837 Default,
838 Display,
839 Hash,
840 PartialEq,
841 Eq,
842 PartialOrd,
843 Ord,
844 AsRefStr,
845 FromRepr,
846 EnumIter,
847 EnumString,
848)]
849#[strum(ascii_case_insensitive)]
850#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
851#[allow(clippy::enum_variant_names)]
852#[cfg_attr(
853 feature = "python",
854 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
855)]
856pub enum OrderSide {
857 #[default]
859 NoOrderSide = 0,
860 Buy = 1,
862 Sell = 2,
864}
865
866impl OrderSide {
867 #[must_use]
873 pub fn as_specified(&self) -> OrderSideSpecified {
874 match &self {
875 Self::Buy => OrderSideSpecified::Buy,
876 Self::Sell => OrderSideSpecified::Sell,
877 _ => panic!("Order invariant failed: side must be `Buy` or `Sell`"),
878 }
879 }
880}
881
882impl FromU8 for OrderSide {
884 fn from_u8(value: u8) -> Option<Self> {
885 match value {
886 0 => Some(Self::NoOrderSide),
887 1 => Some(Self::Buy),
888 2 => Some(Self::Sell),
889 _ => None,
890 }
891 }
892}
893
894#[repr(C)]
896#[derive(
897 Copy,
898 Clone,
899 Debug,
900 Display,
901 Hash,
902 PartialEq,
903 Eq,
904 PartialOrd,
905 Ord,
906 AsRefStr,
907 FromRepr,
908 EnumIter,
909 EnumString,
910)]
911#[strum(ascii_case_insensitive)]
912#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
913#[allow(clippy::enum_variant_names)]
914pub enum OrderSideSpecified {
915 Buy = 1,
917 Sell = 2,
919}
920
921impl OrderSideSpecified {
922 #[must_use]
924 pub fn opposite(&self) -> Self {
925 match &self {
926 Self::Buy => Self::Sell,
927 Self::Sell => Self::Buy,
928 }
929 }
930
931 #[must_use]
933 pub fn as_order_side(&self) -> OrderSide {
934 match &self {
935 Self::Buy => OrderSide::Buy,
936 Self::Sell => OrderSide::Sell,
937 }
938 }
939}
940
941#[repr(C)]
962#[derive(
963 Copy,
964 Clone,
965 Debug,
966 Display,
967 Hash,
968 PartialEq,
969 Eq,
970 PartialOrd,
971 Ord,
972 AsRefStr,
973 FromRepr,
974 EnumIter,
975 EnumString,
976)]
977#[strum(ascii_case_insensitive)]
978#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
979#[cfg_attr(
980 feature = "python",
981 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
982)]
983pub enum OrderStatus {
984 Initialized = 1,
986 Denied = 2,
988 Emulated = 3,
990 Released = 4,
992 Submitted = 5,
994 Accepted = 6,
996 Rejected = 7,
998 Canceled = 8,
1000 Expired = 9,
1002 Triggered = 10,
1004 PendingUpdate = 11,
1006 PendingCancel = 12,
1008 PartiallyFilled = 13,
1010 Filled = 14,
1012}
1013
1014impl OrderStatus {
1015 #[must_use]
1030 pub fn cancellable_statuses_set() -> &'static AHashSet<Self> {
1031 static CANCELLABLE_SET: OnceLock<AHashSet<OrderStatus>> = OnceLock::new();
1032 CANCELLABLE_SET.get_or_init(|| {
1033 AHashSet::from_iter([
1034 Self::Accepted,
1035 Self::Triggered,
1036 Self::PendingUpdate,
1037 Self::PartiallyFilled,
1038 ])
1039 })
1040 }
1041}
1042
1043#[repr(C)]
1045#[derive(
1046 Copy,
1047 Clone,
1048 Debug,
1049 Display,
1050 Hash,
1051 PartialEq,
1052 Eq,
1053 PartialOrd,
1054 Ord,
1055 AsRefStr,
1056 FromRepr,
1057 EnumIter,
1058 EnumString,
1059)]
1060#[strum(ascii_case_insensitive)]
1061#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1062#[cfg_attr(
1063 feature = "python",
1064 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1065)]
1066pub enum OrderType {
1067 Market = 1,
1069 Limit = 2,
1071 StopMarket = 3,
1073 StopLimit = 4,
1075 MarketToLimit = 5,
1077 MarketIfTouched = 6,
1079 LimitIfTouched = 7,
1081 TrailingStopMarket = 8,
1083 TrailingStopLimit = 9,
1085}
1086
1087#[repr(C)]
1089#[derive(
1090 Copy,
1091 Clone,
1092 Debug,
1093 Default,
1094 Display,
1095 Hash,
1096 PartialEq,
1097 Eq,
1098 PartialOrd,
1099 Ord,
1100 AsRefStr,
1101 FromRepr,
1102 EnumIter,
1103 EnumString,
1104)]
1105#[strum(ascii_case_insensitive)]
1106#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1107#[allow(clippy::enum_variant_names)]
1108#[cfg_attr(
1109 feature = "python",
1110 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1111)]
1112pub enum PositionSide {
1113 #[default]
1115 NoPositionSide = 0,
1116 Flat = 1,
1118 Long = 2,
1120 Short = 3,
1122}
1123
1124impl PositionSide {
1125 #[must_use]
1131 pub fn as_specified(&self) -> PositionSideSpecified {
1132 match &self {
1133 Self::Long => PositionSideSpecified::Long,
1134 Self::Short => PositionSideSpecified::Short,
1135 Self::Flat => PositionSideSpecified::Flat,
1136 _ => panic!("Position invariant failed: side must be `Long`, `Short`, or `Flat`"),
1137 }
1138 }
1139}
1140
1141#[repr(C)]
1143#[derive(
1144 Copy,
1145 Clone,
1146 Debug,
1147 Display,
1148 Hash,
1149 PartialEq,
1150 Eq,
1151 PartialOrd,
1152 Ord,
1153 AsRefStr,
1154 FromRepr,
1155 EnumIter,
1156 EnumString,
1157)]
1158#[strum(ascii_case_insensitive)]
1159#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1160#[allow(clippy::enum_variant_names)]
1161#[cfg_attr(
1162 feature = "python",
1163 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1164)]
1165pub enum PositionSideSpecified {
1166 Flat = 1,
1168 Long = 2,
1170 Short = 3,
1172}
1173
1174impl PositionSideSpecified {
1175 #[must_use]
1177 pub fn as_position_side(&self) -> PositionSide {
1178 match &self {
1179 Self::Long => PositionSide::Long,
1180 Self::Short => PositionSide::Short,
1181 Self::Flat => PositionSide::Flat,
1182 }
1183 }
1184}
1185
1186#[repr(C)]
1188#[derive(
1189 Copy,
1190 Clone,
1191 Debug,
1192 Display,
1193 Hash,
1194 PartialEq,
1195 Eq,
1196 PartialOrd,
1197 Ord,
1198 AsRefStr,
1199 FromRepr,
1200 EnumIter,
1201 EnumString,
1202)]
1203#[strum(ascii_case_insensitive)]
1204#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1205#[cfg_attr(
1206 feature = "python",
1207 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1208)]
1209pub enum PriceType {
1210 Bid = 1,
1213 Ask = 2,
1216 Mid = 3,
1218 Last = 4,
1220 Mark = 5,
1223}
1224
1225#[repr(C)]
1227#[derive(
1228 Copy,
1229 Clone,
1230 Debug,
1231 Display,
1232 Hash,
1233 PartialEq,
1234 Eq,
1235 PartialOrd,
1236 Ord,
1237 AsRefStr,
1238 FromRepr,
1239 EnumIter,
1240 EnumString,
1241)]
1242#[strum(ascii_case_insensitive)]
1243#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1244#[cfg_attr(
1245 feature = "python",
1246 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1247)]
1248#[allow(non_camel_case_types)]
1249pub enum RecordFlag {
1250 F_LAST = 1 << 7, F_TOB = 1 << 6, F_SNAPSHOT = 1 << 5, F_MBP = 1 << 4, RESERVED_2 = 1 << 3, RESERVED_1 = 1 << 2, }
1263
1264impl RecordFlag {
1265 #[must_use]
1267 pub fn matches(self, value: u8) -> bool {
1268 (self as u8) & value != 0
1269 }
1270}
1271
1272#[repr(C)]
1274#[derive(
1275 Copy,
1276 Clone,
1277 Debug,
1278 Display,
1279 Hash,
1280 PartialEq,
1281 Eq,
1282 PartialOrd,
1283 Ord,
1284 AsRefStr,
1285 FromRepr,
1286 EnumIter,
1287 EnumString,
1288)]
1289#[strum(ascii_case_insensitive)]
1290#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1291#[cfg_attr(
1292 feature = "python",
1293 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1294)]
1295pub enum TimeInForce {
1296 Gtc = 1,
1298 Ioc = 2,
1300 Fok = 3,
1302 Gtd = 4,
1304 Day = 5,
1306 AtTheOpen = 6,
1308 AtTheClose = 7,
1310}
1311
1312#[repr(C)]
1314#[derive(
1315 Copy,
1316 Clone,
1317 Debug,
1318 Display,
1319 Hash,
1320 PartialEq,
1321 Eq,
1322 PartialOrd,
1323 Ord,
1324 AsRefStr,
1325 FromRepr,
1326 EnumIter,
1327 EnumString,
1328)]
1329#[strum(ascii_case_insensitive)]
1330#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1331#[cfg_attr(
1332 feature = "python",
1333 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1334)]
1335pub enum TradingState {
1336 Active = 1,
1338 Halted = 2,
1340 Reducing = 3,
1342}
1343
1344#[repr(C)]
1346#[derive(
1347 Copy,
1348 Clone,
1349 Debug,
1350 Default,
1351 Display,
1352 Hash,
1353 PartialEq,
1354 Eq,
1355 PartialOrd,
1356 Ord,
1357 AsRefStr,
1358 FromRepr,
1359 EnumIter,
1360 EnumString,
1361)]
1362#[strum(ascii_case_insensitive)]
1363#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1364#[cfg_attr(
1365 feature = "python",
1366 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1367)]
1368pub enum TrailingOffsetType {
1369 #[default]
1371 NoTrailingOffset = 0,
1372 Price = 1,
1374 BasisPoints = 2,
1376 Ticks = 3,
1378 PriceTier = 4,
1380}
1381
1382#[repr(C)]
1384#[derive(
1385 Copy,
1386 Clone,
1387 Debug,
1388 Default,
1389 Display,
1390 Hash,
1391 PartialEq,
1392 Eq,
1393 PartialOrd,
1394 Ord,
1395 AsRefStr,
1396 FromRepr,
1397 EnumIter,
1398 EnumString,
1399)]
1400#[strum(ascii_case_insensitive)]
1401#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1402#[cfg_attr(
1403 feature = "python",
1404 pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1405)]
1406pub enum TriggerType {
1407 #[default]
1409 NoTrigger = 0,
1410 Default = 1,
1412 LastPrice = 2,
1414 MarkPrice = 3,
1416 IndexPrice = 4,
1418 BidAsk = 5,
1420 DoubleLast = 6,
1422 DoubleBidAsk = 7,
1424 LastOrBidAsk = 8,
1426 MidPoint = 9,
1428}
1429
1430enum_strum_serde!(AccountType);
1431enum_strum_serde!(AggregationSource);
1432enum_strum_serde!(AggressorSide);
1433enum_strum_serde!(AssetClass);
1434enum_strum_serde!(InstrumentClass);
1435enum_strum_serde!(BarAggregation);
1436enum_strum_serde!(BarIntervalType);
1437enum_strum_serde!(BookAction);
1438enum_strum_serde!(BookType);
1439enum_strum_serde!(ContingencyType);
1440enum_strum_serde!(CurrencyType);
1441enum_strum_serde!(InstrumentCloseType);
1442enum_strum_serde!(LiquiditySide);
1443enum_strum_serde!(MarketStatus);
1444enum_strum_serde!(MarketStatusAction);
1445enum_strum_serde!(OmsType);
1446enum_strum_serde!(OptionKind);
1447enum_strum_serde!(OrderSide);
1448enum_strum_serde!(OrderSideSpecified);
1449enum_strum_serde!(OrderStatus);
1450enum_strum_serde!(OrderType);
1451enum_strum_serde!(PositionSide);
1452enum_strum_serde!(PositionSideSpecified);
1453enum_strum_serde!(PriceType);
1454enum_strum_serde!(RecordFlag);
1455enum_strum_serde!(TimeInForce);
1456enum_strum_serde!(TradingState);
1457enum_strum_serde!(TrailingOffsetType);
1458enum_strum_serde!(TriggerType);