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(
68 frozen,
69 eq,
70 eq_int,
71 hash,
72 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
73 )
74)]
75pub enum AccountType {
76 Cash = 1,
78 Margin = 2,
80 Betting = 3,
82}
83
84#[repr(C)]
86#[derive(
87 Copy,
88 Clone,
89 Debug,
90 Display,
91 Hash,
92 PartialEq,
93 Eq,
94 PartialOrd,
95 Ord,
96 AsRefStr,
97 FromRepr,
98 EnumIter,
99 EnumString,
100)]
101#[strum(ascii_case_insensitive)]
102#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
103#[cfg_attr(
104 feature = "python",
105 pyo3::pyclass(
106 frozen,
107 eq,
108 eq_int,
109 hash,
110 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
111 )
112)]
113pub enum AggregationSource {
114 External = 1,
116 Internal = 2,
118}
119
120#[repr(C)]
122#[derive(
123 Copy,
124 Clone,
125 Debug,
126 Default,
127 Display,
128 Hash,
129 PartialEq,
130 Eq,
131 PartialOrd,
132 Ord,
133 AsRefStr,
134 FromRepr,
135 EnumIter,
136 EnumString,
137)]
138#[strum(ascii_case_insensitive)]
139#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
140#[cfg_attr(
141 feature = "python",
142 pyo3::pyclass(
143 frozen,
144 eq,
145 eq_int,
146 hash,
147 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
148 )
149)]
150pub enum AggressorSide {
151 #[default]
153 NoAggressor = 0,
154 Buyer = 1,
156 Seller = 2,
158}
159
160impl FromU8 for AggressorSide {
161 fn from_u8(value: u8) -> Option<Self> {
162 match value {
163 0 => Some(Self::NoAggressor),
164 1 => Some(Self::Buyer),
165 2 => Some(Self::Seller),
166 _ => None,
167 }
168 }
169}
170
171#[repr(C)]
173#[derive(
174 Copy,
175 Clone,
176 Debug,
177 Display,
178 Hash,
179 PartialEq,
180 Eq,
181 PartialOrd,
182 Ord,
183 AsRefStr,
184 FromRepr,
185 EnumIter,
186 EnumString,
187)]
188#[strum(ascii_case_insensitive)]
189#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
190#[cfg_attr(
191 feature = "python",
192 pyo3::pyclass(
193 frozen,
194 eq,
195 eq_int,
196 hash,
197 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
198 )
199)]
200#[allow(non_camel_case_types)]
201pub enum AssetClass {
202 FX = 1,
204 Equity = 2,
206 Commodity = 3,
208 Debt = 4,
210 Index = 5,
212 Cryptocurrency = 6,
214 Alternative = 7,
216}
217
218impl FromU8 for AssetClass {
219 fn from_u8(value: u8) -> Option<Self> {
220 match value {
221 1 => Some(Self::FX),
222 2 => Some(Self::Equity),
223 3 => Some(Self::Commodity),
224 4 => Some(Self::Debt),
225 5 => Some(Self::Index),
226 6 => Some(Self::Cryptocurrency),
227 7 => Some(Self::Alternative),
228 _ => None,
229 }
230 }
231}
232
233#[repr(C)]
235#[derive(
236 Copy,
237 Clone,
238 Debug,
239 Display,
240 Hash,
241 PartialEq,
242 Eq,
243 PartialOrd,
244 Ord,
245 AsRefStr,
246 FromRepr,
247 EnumIter,
248 EnumString,
249)]
250#[strum(ascii_case_insensitive)]
251#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
252#[cfg_attr(
253 feature = "python",
254 pyo3::pyclass(
255 frozen,
256 eq,
257 eq_int,
258 hash,
259 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
260 )
261)]
262pub enum InstrumentClass {
263 Spot = 1,
265 Swap = 2,
267 Future = 3,
269 FuturesSpread = 4,
271 Forward = 5,
273 Cfd = 6,
275 Bond = 7,
277 Option = 8,
279 OptionSpread = 9,
281 Warrant = 10,
283 SportsBetting = 11,
285 BinaryOption = 12,
288}
289
290#[repr(C)]
292#[derive(
293 Copy,
294 Clone,
295 Debug,
296 Display,
297 Hash,
298 PartialEq,
299 Eq,
300 PartialOrd,
301 Ord,
302 AsRefStr,
303 FromRepr,
304 EnumIter,
305 EnumString,
306)]
307#[strum(ascii_case_insensitive)]
308#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
309#[cfg_attr(
310 feature = "python",
311 pyo3::pyclass(
312 frozen,
313 eq,
314 eq_int,
315 hash,
316 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
317 )
318)]
319pub enum BarAggregation {
320 Tick = 1,
322 TickImbalance = 2,
324 TickRuns = 3,
326 Volume = 4,
328 VolumeImbalance = 5,
330 VolumeRuns = 6,
332 Value = 7,
334 ValueImbalance = 8,
336 ValueRuns = 9,
338 Millisecond = 10,
340 Second = 11,
342 Minute = 12,
344 Hour = 13,
346 Day = 14,
348 Week = 15,
350 Month = 16,
352 Year = 17,
354 Renko = 18,
356}
357
358#[repr(C)]
360#[derive(
361 Copy,
362 Clone,
363 Debug,
364 Default,
365 Display,
366 Hash,
367 PartialEq,
368 Eq,
369 PartialOrd,
370 Ord,
371 AsRefStr,
372 FromRepr,
373 EnumIter,
374 EnumString,
375)]
376#[strum(ascii_case_insensitive)]
377#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
378#[cfg_attr(
379 feature = "python",
380 pyo3::pyclass(
381 frozen,
382 eq,
383 eq_int,
384 hash,
385 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
386 )
387)]
388pub enum BarIntervalType {
389 #[default]
391 LeftOpen = 1,
392 RightOpen = 2,
394}
395
396#[repr(C)]
398#[derive(
399 Copy,
400 Clone,
401 Debug,
402 Display,
403 Hash,
404 PartialEq,
405 Eq,
406 PartialOrd,
407 Ord,
408 AsRefStr,
409 FromRepr,
410 EnumIter,
411 EnumString,
412)]
413#[strum(ascii_case_insensitive)]
414#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
415#[cfg_attr(
416 feature = "python",
417 pyo3::pyclass(
418 frozen,
419 eq,
420 eq_int,
421 hash,
422 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
423 )
424)]
425pub enum BetSide {
426 Back = 1,
428 Lay = 2,
430}
431
432impl BetSide {
433 #[must_use]
435 pub fn opposite(&self) -> Self {
436 match self {
437 Self::Back => Self::Lay,
438 Self::Lay => Self::Back,
439 }
440 }
441}
442
443impl From<OrderSide> for BetSide {
444 fn from(side: OrderSide) -> Self {
450 match side {
451 OrderSide::Buy => Self::Back,
452 OrderSide::Sell => Self::Lay,
453 OrderSide::NoOrderSide => panic!("Invalid `OrderSide` for `BetSide`, was {side}"),
454 }
455 }
456}
457
458#[repr(C)]
460#[derive(
461 Copy,
462 Clone,
463 Debug,
464 Display,
465 Hash,
466 PartialEq,
467 Eq,
468 PartialOrd,
469 Ord,
470 AsRefStr,
471 FromRepr,
472 EnumIter,
473 EnumString,
474)]
475#[strum(ascii_case_insensitive)]
476#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
477#[cfg_attr(
478 feature = "python",
479 pyo3::pyclass(
480 frozen,
481 eq,
482 eq_int,
483 hash,
484 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
485 )
486)]
487pub enum BookAction {
488 Add = 1,
490 Update = 2,
492 Delete = 3,
494 Clear = 4,
496}
497
498impl FromU8 for BookAction {
499 fn from_u8(value: u8) -> Option<Self> {
500 match value {
501 1 => Some(Self::Add),
502 2 => Some(Self::Update),
503 3 => Some(Self::Delete),
504 4 => Some(Self::Clear),
505 _ => None,
506 }
507 }
508}
509
510#[repr(C)]
512#[derive(
513 Copy,
514 Clone,
515 Debug,
516 Display,
517 Hash,
518 PartialEq,
519 Eq,
520 PartialOrd,
521 Ord,
522 AsRefStr,
523 FromRepr,
524 EnumIter,
525 EnumString,
526)]
527#[strum(ascii_case_insensitive)]
528#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
529#[allow(non_camel_case_types)]
530#[cfg_attr(
531 feature = "python",
532 pyo3::pyclass(
533 frozen,
534 eq,
535 eq_int,
536 hash,
537 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
538 )
539)]
540pub enum BookType {
541 L1_MBP = 1,
543 L2_MBP = 2,
545 L3_MBO = 3,
547}
548
549impl FromU8 for BookType {
550 fn from_u8(value: u8) -> Option<Self> {
551 match value {
552 1 => Some(Self::L1_MBP),
553 2 => Some(Self::L2_MBP),
554 3 => Some(Self::L3_MBO),
555 _ => None,
556 }
557 }
558}
559
560#[repr(C)]
564#[derive(
565 Copy,
566 Clone,
567 Debug,
568 Default,
569 Display,
570 Hash,
571 PartialEq,
572 Eq,
573 PartialOrd,
574 Ord,
575 AsRefStr,
576 FromRepr,
577 EnumIter,
578 EnumString,
579)]
580#[strum(ascii_case_insensitive)]
581#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
582#[cfg_attr(
583 feature = "python",
584 pyo3::pyclass(
585 frozen,
586 eq,
587 eq_int,
588 hash,
589 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
590 )
591)]
592pub enum ContingencyType {
593 #[default]
595 NoContingency = 0,
596 Oco = 1,
598 Oto = 2,
600 Ouo = 3,
602}
603
604#[repr(C)]
606#[derive(
607 Copy,
608 Clone,
609 Debug,
610 Display,
611 Hash,
612 PartialEq,
613 Eq,
614 PartialOrd,
615 Ord,
616 AsRefStr,
617 FromRepr,
618 EnumIter,
619 EnumString,
620)]
621#[strum(ascii_case_insensitive)]
622#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
623#[cfg_attr(
624 feature = "python",
625 pyo3::pyclass(
626 frozen,
627 eq,
628 eq_int,
629 hash,
630 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
631 )
632)]
633pub enum CurrencyType {
634 Crypto = 1,
636 Fiat = 2,
638 CommodityBacked = 3,
640}
641
642#[repr(C)]
644#[derive(
645 Copy,
646 Clone,
647 Debug,
648 Display,
649 Hash,
650 PartialEq,
651 Eq,
652 PartialOrd,
653 Ord,
654 AsRefStr,
655 FromRepr,
656 EnumIter,
657 EnumString,
658)]
659#[strum(ascii_case_insensitive)]
660#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
661#[cfg_attr(
662 feature = "python",
663 pyo3::pyclass(
664 frozen,
665 eq,
666 eq_int,
667 hash,
668 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
669 )
670)]
671pub enum InstrumentCloseType {
672 EndOfSession = 1,
674 ContractExpired = 2,
676}
677
678impl FromU8 for InstrumentCloseType {
680 fn from_u8(value: u8) -> Option<Self> {
681 match value {
682 1 => Some(Self::EndOfSession),
683 2 => Some(Self::ContractExpired),
684 _ => None,
685 }
686 }
687}
688
689#[repr(C)]
691#[derive(
692 Copy,
693 Clone,
694 Debug,
695 Display,
696 Hash,
697 PartialEq,
698 Eq,
699 PartialOrd,
700 Ord,
701 AsRefStr,
702 FromRepr,
703 EnumIter,
704 EnumString,
705)]
706#[strum(ascii_case_insensitive)]
707#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
708#[cfg_attr(
709 feature = "python",
710 pyo3::pyclass(
711 frozen,
712 eq,
713 eq_int,
714 hash,
715 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
716 )
717)]
718#[allow(clippy::enum_variant_names)]
719pub enum LiquiditySide {
720 NoLiquiditySide = 0,
722 Maker = 1,
724 Taker = 2,
726}
727
728#[repr(C)]
730#[derive(
731 Copy,
732 Clone,
733 Debug,
734 Display,
735 Hash,
736 PartialEq,
737 Eq,
738 PartialOrd,
739 Ord,
740 AsRefStr,
741 FromRepr,
742 EnumIter,
743 EnumString,
744)]
745#[strum(ascii_case_insensitive)]
746#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
747#[cfg_attr(
748 feature = "python",
749 pyo3::pyclass(
750 frozen,
751 eq,
752 eq_int,
753 hash,
754 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
755 )
756)]
757pub enum MarketStatus {
758 Open = 1,
760 Closed = 2,
762 Paused = 3,
764 Suspended = 5,
768 NotAvailable = 6,
770}
771
772#[repr(C)]
774#[derive(
775 Copy,
776 Clone,
777 Debug,
778 Display,
779 Hash,
780 PartialEq,
781 Eq,
782 PartialOrd,
783 Ord,
784 AsRefStr,
785 FromRepr,
786 EnumIter,
787 EnumString,
788)]
789#[strum(ascii_case_insensitive)]
790#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
791#[cfg_attr(
792 feature = "python",
793 pyo3::pyclass(
794 frozen,
795 eq,
796 eq_int,
797 hash,
798 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
799 )
800)]
801pub enum MarketStatusAction {
802 None = 0,
804 PreOpen = 1,
806 PreCross = 2,
808 Quoting = 3,
810 Cross = 4,
812 Rotation = 5,
814 NewPriceIndication = 6,
816 Trading = 7,
818 Halt = 8,
820 Pause = 9,
822 Suspend = 10,
824 PreClose = 11,
826 Close = 12,
828 PostClose = 13,
830 ShortSellRestrictionChange = 14,
832 NotAvailableForTrading = 15,
834}
835
836impl FromU16 for MarketStatusAction {
838 fn from_u16(value: u16) -> Option<Self> {
839 match value {
840 0 => Some(Self::None),
841 1 => Some(Self::PreOpen),
842 2 => Some(Self::PreCross),
843 3 => Some(Self::Quoting),
844 4 => Some(Self::Cross),
845 5 => Some(Self::Rotation),
846 6 => Some(Self::NewPriceIndication),
847 7 => Some(Self::Trading),
848 8 => Some(Self::Halt),
849 9 => Some(Self::Pause),
850 10 => Some(Self::Suspend),
851 11 => Some(Self::PreClose),
852 12 => Some(Self::Close),
853 13 => Some(Self::PostClose),
854 14 => Some(Self::ShortSellRestrictionChange),
855 15 => Some(Self::NotAvailableForTrading),
856 _ => None,
857 }
858 }
859}
860
861#[repr(C)]
863#[derive(
864 Copy,
865 Clone,
866 Debug,
867 Default,
868 Display,
869 Hash,
870 PartialEq,
871 Eq,
872 PartialOrd,
873 Ord,
874 AsRefStr,
875 FromRepr,
876 EnumIter,
877 EnumString,
878)]
879#[strum(ascii_case_insensitive)]
880#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
881#[cfg_attr(
882 feature = "python",
883 pyo3::pyclass(
884 frozen,
885 eq,
886 eq_int,
887 hash,
888 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
889 )
890)]
891pub enum OmsType {
892 #[default]
894 Unspecified = 0,
895 Netting = 1,
897 Hedging = 2,
901}
902
903#[repr(C)]
905#[derive(
906 Copy,
907 Clone,
908 Debug,
909 Display,
910 Hash,
911 PartialEq,
912 Eq,
913 PartialOrd,
914 Ord,
915 AsRefStr,
916 FromRepr,
917 EnumIter,
918 EnumString,
919)]
920#[strum(ascii_case_insensitive)]
921#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
922#[cfg_attr(
923 feature = "python",
924 pyo3::pyclass(
925 frozen,
926 eq,
927 eq_int,
928 hash,
929 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
930 )
931)]
932pub enum OptionKind {
933 Call = 1,
935 Put = 2,
937}
938
939#[repr(C)]
941#[derive(
942 Copy,
943 Clone,
944 Debug,
945 Default,
946 Display,
947 Hash,
948 PartialEq,
949 Eq,
950 PartialOrd,
951 Ord,
952 AsRefStr,
953 FromRepr,
954 EnumIter,
955 EnumString,
956)]
957#[strum(ascii_case_insensitive)]
958#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
959#[allow(clippy::enum_variant_names)]
960#[cfg_attr(
961 feature = "python",
962 pyo3::pyclass(
963 frozen,
964 eq,
965 eq_int,
966 hash,
967 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
968 )
969)]
970pub enum OrderSide {
971 #[default]
973 NoOrderSide = 0,
974 Buy = 1,
976 Sell = 2,
978}
979
980impl OrderSide {
981 #[must_use]
987 pub fn as_specified(&self) -> OrderSideSpecified {
988 match &self {
989 Self::Buy => OrderSideSpecified::Buy,
990 Self::Sell => OrderSideSpecified::Sell,
991 _ => panic!("Order invariant failed: side must be `Buy` or `Sell`"),
992 }
993 }
994}
995
996impl FromU8 for OrderSide {
998 fn from_u8(value: u8) -> Option<Self> {
999 match value {
1000 0 => Some(Self::NoOrderSide),
1001 1 => Some(Self::Buy),
1002 2 => Some(Self::Sell),
1003 _ => None,
1004 }
1005 }
1006}
1007
1008#[repr(C)]
1010#[derive(
1011 Copy,
1012 Clone,
1013 Debug,
1014 Display,
1015 Hash,
1016 PartialEq,
1017 Eq,
1018 PartialOrd,
1019 Ord,
1020 AsRefStr,
1021 FromRepr,
1022 EnumIter,
1023 EnumString,
1024)]
1025#[strum(ascii_case_insensitive)]
1026#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1027#[allow(clippy::enum_variant_names)]
1028pub enum OrderSideSpecified {
1029 Buy = 1,
1031 Sell = 2,
1033}
1034
1035impl OrderSideSpecified {
1036 #[must_use]
1038 pub fn opposite(&self) -> Self {
1039 match &self {
1040 Self::Buy => Self::Sell,
1041 Self::Sell => Self::Buy,
1042 }
1043 }
1044
1045 #[must_use]
1047 pub fn as_order_side(&self) -> OrderSide {
1048 match &self {
1049 Self::Buy => OrderSide::Buy,
1050 Self::Sell => OrderSide::Sell,
1051 }
1052 }
1053}
1054
1055#[repr(C)]
1076#[derive(
1077 Copy,
1078 Clone,
1079 Debug,
1080 Display,
1081 Hash,
1082 PartialEq,
1083 Eq,
1084 PartialOrd,
1085 Ord,
1086 AsRefStr,
1087 FromRepr,
1088 EnumIter,
1089 EnumString,
1090)]
1091#[strum(ascii_case_insensitive)]
1092#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1093#[cfg_attr(
1094 feature = "python",
1095 pyo3::pyclass(
1096 frozen,
1097 eq,
1098 eq_int,
1099 hash,
1100 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1101 )
1102)]
1103pub enum OrderStatus {
1104 Initialized = 1,
1106 Denied = 2,
1108 Emulated = 3,
1110 Released = 4,
1112 Submitted = 5,
1114 Accepted = 6,
1116 Rejected = 7,
1118 Canceled = 8,
1120 Expired = 9,
1122 Triggered = 10,
1124 PendingUpdate = 11,
1126 PendingCancel = 12,
1128 PartiallyFilled = 13,
1130 Filled = 14,
1132}
1133
1134impl OrderStatus {
1135 #[must_use]
1150 pub fn cancellable_statuses_set() -> &'static AHashSet<Self> {
1151 static CANCELLABLE_SET: OnceLock<AHashSet<OrderStatus>> = OnceLock::new();
1152 CANCELLABLE_SET.get_or_init(|| {
1153 AHashSet::from_iter([
1154 Self::Accepted,
1155 Self::Triggered,
1156 Self::PendingUpdate,
1157 Self::PartiallyFilled,
1158 ])
1159 })
1160 }
1161}
1162
1163#[repr(C)]
1165#[derive(
1166 Copy,
1167 Clone,
1168 Debug,
1169 Display,
1170 Hash,
1171 PartialEq,
1172 Eq,
1173 PartialOrd,
1174 Ord,
1175 AsRefStr,
1176 FromRepr,
1177 EnumIter,
1178 EnumString,
1179)]
1180#[strum(ascii_case_insensitive)]
1181#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1182#[cfg_attr(
1183 feature = "python",
1184 pyo3::pyclass(
1185 frozen,
1186 eq,
1187 eq_int,
1188 hash,
1189 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1190 )
1191)]
1192pub enum OrderType {
1193 Market = 1,
1195 Limit = 2,
1197 StopMarket = 3,
1199 StopLimit = 4,
1201 MarketToLimit = 5,
1203 MarketIfTouched = 6,
1205 LimitIfTouched = 7,
1207 TrailingStopMarket = 8,
1209 TrailingStopLimit = 9,
1211}
1212
1213#[repr(C)]
1215#[derive(
1216 Copy,
1217 Clone,
1218 Debug,
1219 Default,
1220 Display,
1221 Hash,
1222 PartialEq,
1223 Eq,
1224 PartialOrd,
1225 Ord,
1226 AsRefStr,
1227 FromRepr,
1228 EnumIter,
1229 EnumString,
1230)]
1231#[strum(ascii_case_insensitive)]
1232#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1233#[allow(clippy::enum_variant_names)]
1234#[cfg_attr(
1235 feature = "python",
1236 pyo3::pyclass(
1237 frozen,
1238 eq,
1239 eq_int,
1240 hash,
1241 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1242 )
1243)]
1244pub enum PositionSide {
1245 #[default]
1247 NoPositionSide = 0,
1248 Flat = 1,
1250 Long = 2,
1252 Short = 3,
1254}
1255
1256impl PositionSide {
1257 #[must_use]
1263 pub fn as_specified(&self) -> PositionSideSpecified {
1264 match &self {
1265 Self::Long => PositionSideSpecified::Long,
1266 Self::Short => PositionSideSpecified::Short,
1267 Self::Flat => PositionSideSpecified::Flat,
1268 _ => panic!("Position invariant failed: side must be `Long`, `Short`, or `Flat`"),
1269 }
1270 }
1271}
1272
1273#[repr(C)]
1275#[derive(
1276 Copy,
1277 Clone,
1278 Debug,
1279 Display,
1280 Hash,
1281 PartialEq,
1282 Eq,
1283 PartialOrd,
1284 Ord,
1285 AsRefStr,
1286 FromRepr,
1287 EnumIter,
1288 EnumString,
1289)]
1290#[strum(ascii_case_insensitive)]
1291#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1292#[allow(clippy::enum_variant_names)]
1293#[cfg_attr(
1294 feature = "python",
1295 pyo3::pyclass(
1296 frozen,
1297 eq,
1298 eq_int,
1299 hash,
1300 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1301 )
1302)]
1303pub enum PositionSideSpecified {
1304 Flat = 1,
1306 Long = 2,
1308 Short = 3,
1310}
1311
1312impl PositionSideSpecified {
1313 #[must_use]
1315 pub fn as_position_side(&self) -> PositionSide {
1316 match &self {
1317 Self::Long => PositionSide::Long,
1318 Self::Short => PositionSide::Short,
1319 Self::Flat => PositionSide::Flat,
1320 }
1321 }
1322}
1323
1324#[repr(C)]
1326#[derive(
1327 Copy,
1328 Clone,
1329 Debug,
1330 Display,
1331 Hash,
1332 PartialEq,
1333 Eq,
1334 PartialOrd,
1335 Ord,
1336 AsRefStr,
1337 FromRepr,
1338 EnumIter,
1339 EnumString,
1340)]
1341#[strum(ascii_case_insensitive)]
1342#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1343#[cfg_attr(
1344 feature = "python",
1345 pyo3::pyclass(
1346 frozen,
1347 eq,
1348 eq_int,
1349 hash,
1350 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1351 )
1352)]
1353pub enum PriceType {
1354 Bid = 1,
1357 Ask = 2,
1360 Mid = 3,
1362 Last = 4,
1364 Mark = 5,
1367}
1368
1369#[repr(C)]
1371#[derive(
1372 Copy,
1373 Clone,
1374 Debug,
1375 Display,
1376 Hash,
1377 PartialEq,
1378 Eq,
1379 PartialOrd,
1380 Ord,
1381 AsRefStr,
1382 FromRepr,
1383 EnumIter,
1384 EnumString,
1385)]
1386#[strum(ascii_case_insensitive)]
1387#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1388#[cfg_attr(
1389 feature = "python",
1390 pyo3::pyclass(
1391 frozen,
1392 eq,
1393 eq_int,
1394 hash,
1395 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1396 )
1397)]
1398#[allow(non_camel_case_types)]
1399pub enum RecordFlag {
1400 F_LAST = 1 << 7, F_TOB = 1 << 6, F_SNAPSHOT = 1 << 5, F_MBP = 1 << 4, RESERVED_2 = 1 << 3, RESERVED_1 = 1 << 2, }
1413
1414impl RecordFlag {
1415 #[must_use]
1417 pub fn matches(self, value: u8) -> bool {
1418 (self as u8) & value != 0
1419 }
1420}
1421
1422#[repr(C)]
1424#[derive(
1425 Copy,
1426 Clone,
1427 Debug,
1428 Display,
1429 Hash,
1430 PartialEq,
1431 Eq,
1432 PartialOrd,
1433 Ord,
1434 AsRefStr,
1435 FromRepr,
1436 EnumIter,
1437 EnumString,
1438)]
1439#[strum(ascii_case_insensitive)]
1440#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1441#[cfg_attr(
1442 feature = "python",
1443 pyo3::pyclass(
1444 frozen,
1445 eq,
1446 eq_int,
1447 hash,
1448 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1449 )
1450)]
1451pub enum TimeInForce {
1452 Gtc = 1,
1454 Ioc = 2,
1456 Fok = 3,
1458 Gtd = 4,
1460 Day = 5,
1462 AtTheOpen = 6,
1464 AtTheClose = 7,
1466}
1467
1468#[repr(C)]
1470#[derive(
1471 Copy,
1472 Clone,
1473 Debug,
1474 Display,
1475 Hash,
1476 PartialEq,
1477 Eq,
1478 PartialOrd,
1479 Ord,
1480 AsRefStr,
1481 FromRepr,
1482 EnumIter,
1483 EnumString,
1484)]
1485#[strum(ascii_case_insensitive)]
1486#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1487#[cfg_attr(
1488 feature = "python",
1489 pyo3::pyclass(
1490 frozen,
1491 eq,
1492 eq_int,
1493 hash,
1494 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1495 )
1496)]
1497pub enum TradingState {
1498 Active = 1,
1500 Halted = 2,
1502 Reducing = 3,
1504}
1505
1506#[repr(C)]
1508#[derive(
1509 Copy,
1510 Clone,
1511 Debug,
1512 Default,
1513 Display,
1514 Hash,
1515 PartialEq,
1516 Eq,
1517 PartialOrd,
1518 Ord,
1519 AsRefStr,
1520 FromRepr,
1521 EnumIter,
1522 EnumString,
1523)]
1524#[strum(ascii_case_insensitive)]
1525#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1526#[cfg_attr(
1527 feature = "python",
1528 pyo3::pyclass(
1529 frozen,
1530 eq,
1531 eq_int,
1532 hash,
1533 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1534 )
1535)]
1536pub enum TrailingOffsetType {
1537 #[default]
1539 NoTrailingOffset = 0,
1540 Price = 1,
1542 BasisPoints = 2,
1544 Ticks = 3,
1546 PriceTier = 4,
1548}
1549
1550#[repr(C)]
1552#[derive(
1553 Copy,
1554 Clone,
1555 Debug,
1556 Default,
1557 Display,
1558 Hash,
1559 PartialEq,
1560 Eq,
1561 PartialOrd,
1562 Ord,
1563 AsRefStr,
1564 FromRepr,
1565 EnumIter,
1566 EnumString,
1567)]
1568#[strum(ascii_case_insensitive)]
1569#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1570#[cfg_attr(
1571 feature = "python",
1572 pyo3::pyclass(
1573 frozen,
1574 eq,
1575 eq_int,
1576 hash,
1577 module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1578 )
1579)]
1580pub enum TriggerType {
1581 #[default]
1583 NoTrigger = 0,
1584 Default = 1,
1586 LastPrice = 2,
1588 MarkPrice = 3,
1590 IndexPrice = 4,
1592 BidAsk = 5,
1594 DoubleLast = 6,
1596 DoubleBidAsk = 7,
1598 LastOrBidAsk = 8,
1600 MidPoint = 9,
1602}
1603
1604enum_strum_serde!(AccountType);
1605enum_strum_serde!(AggregationSource);
1606enum_strum_serde!(AggressorSide);
1607enum_strum_serde!(AssetClass);
1608enum_strum_serde!(InstrumentClass);
1609enum_strum_serde!(BarAggregation);
1610enum_strum_serde!(BarIntervalType);
1611enum_strum_serde!(BookAction);
1612enum_strum_serde!(BookType);
1613enum_strum_serde!(ContingencyType);
1614enum_strum_serde!(CurrencyType);
1615enum_strum_serde!(InstrumentCloseType);
1616enum_strum_serde!(LiquiditySide);
1617enum_strum_serde!(MarketStatus);
1618enum_strum_serde!(MarketStatusAction);
1619enum_strum_serde!(OmsType);
1620enum_strum_serde!(OptionKind);
1621enum_strum_serde!(OrderSide);
1622enum_strum_serde!(OrderSideSpecified);
1623enum_strum_serde!(OrderStatus);
1624enum_strum_serde!(OrderType);
1625enum_strum_serde!(PositionSide);
1626enum_strum_serde!(PositionSideSpecified);
1627enum_strum_serde!(PriceType);
1628enum_strum_serde!(RecordFlag);
1629enum_strum_serde!(TimeInForce);
1630enum_strum_serde!(TradingState);
1631enum_strum_serde!(TrailingOffsetType);
1632enum_strum_serde!(TriggerType);