1use std::str::FromStr;
19
20use nautilus_core::python::to_pyvalue_err;
21use pyo3::{PyTypeInfo, exceptions::PyValueError, prelude::*, types::PyType};
22
23use crate::{
24 enums::{
25 AccountType, AggregationSource, AggressorSide, AssetClass, BarAggregation, BetSide,
26 BookAction, BookType, ContingencyType, CurrencyType, InstrumentClass, InstrumentCloseType,
27 LiquiditySide, MarketStatus, MarketStatusAction, OmsType, OptionKind, OrderSide,
28 OrderStatus, OrderType, PositionSide, PriceType, RecordFlag, TimeInForce, TradingState,
29 TrailingOffsetType, TriggerType,
30 },
31 python::common::EnumIterator,
32};
33
34#[pymethods]
35impl AccountType {
36 #[new]
37 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
38 let t = Self::type_object(py);
39 Self::py_from_str(&t, value)
40 }
41
42 fn __repr__(&self) -> String {
43 format!(
44 "<{}.{}: '{}'>",
45 stringify!(AccountType),
46 self.name(),
47 self.value(),
48 )
49 }
50
51 fn __str__(&self) -> String {
52 self.to_string()
53 }
54
55 #[getter]
56 #[must_use]
57 pub fn name(&self) -> String {
58 self.to_string()
59 }
60
61 #[getter]
62 #[must_use]
63 pub fn value(&self) -> u8 {
64 *self as u8
65 }
66
67 #[classmethod]
68 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
69 EnumIterator::new::<Self>(py)
70 }
71
72 #[classmethod]
73 #[pyo3(name = "from_str")]
74 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
75 let data_str: &str = data.extract()?;
76 let tokenized = data_str.to_uppercase();
77 Self::from_str(&tokenized).map_err(to_pyvalue_err)
78 }
79
80 #[classattr]
81 #[pyo3(name = "CASH")]
82 fn py_cash() -> Self {
83 Self::Cash
84 }
85
86 #[classattr]
87 #[pyo3(name = "MARGIN")]
88 fn py_margin() -> Self {
89 Self::Margin
90 }
91
92 #[classattr]
93 #[pyo3(name = "BETTING")]
94 fn py_betting() -> Self {
95 Self::Betting
96 }
97}
98
99#[pymethods]
100impl AggregationSource {
101 #[new]
102 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
103 let t = Self::type_object(py);
104 Self::py_from_str(&t, value)
105 }
106
107 fn __repr__(&self) -> String {
108 format!(
109 "<{}.{}: '{}'>",
110 stringify!(AggregationSource),
111 self.name(),
112 self.value(),
113 )
114 }
115
116 fn __str__(&self) -> String {
117 self.to_string()
118 }
119
120 #[getter]
121 #[must_use]
122 pub fn name(&self) -> String {
123 self.to_string()
124 }
125
126 #[getter]
127 #[must_use]
128 pub fn value(&self) -> u8 {
129 *self as u8
130 }
131
132 #[classmethod]
133 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
134 EnumIterator::new::<Self>(py)
135 }
136
137 #[classmethod]
138 #[pyo3(name = "from_str")]
139 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
140 let data_str: &str = data.extract()?;
141 let tokenized = data_str.to_uppercase();
142 Self::from_str(&tokenized).map_err(to_pyvalue_err)
143 }
144
145 #[classattr]
146 #[pyo3(name = "EXTERNAL")]
147 fn py_external() -> Self {
148 Self::External
149 }
150
151 #[classattr]
152 #[pyo3(name = "INTERNAL")]
153 fn py_internal() -> Self {
154 Self::Internal
155 }
156}
157
158#[pymethods]
159impl AggressorSide {
160 #[new]
161 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
162 let t = Self::type_object(py);
163 Self::py_from_str(&t, value)
164 }
165
166 fn __repr__(&self) -> String {
167 format!(
168 "<{}.{}: '{}'>",
169 stringify!(AggressorSide),
170 self.name(),
171 self.value(),
172 )
173 }
174
175 fn __str__(&self) -> String {
176 self.to_string()
177 }
178
179 #[getter]
180 #[must_use]
181 pub fn name(&self) -> String {
182 self.to_string()
183 }
184
185 #[getter]
186 #[must_use]
187 pub fn value(&self) -> u8 {
188 *self as u8
189 }
190
191 #[classmethod]
192 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
193 EnumIterator::new::<Self>(py)
194 }
195
196 #[classmethod]
197 #[pyo3(name = "from_str")]
198 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
199 let data_str: &str = data.extract()?;
200 let tokenized = data_str.to_uppercase();
201 Self::from_str(&tokenized).map_err(to_pyvalue_err)
202 }
203
204 #[classattr]
205 #[pyo3(name = "NO_AGGRESSOR")]
206 fn py_no_aggressor() -> Self {
207 Self::NoAggressor
208 }
209
210 #[classattr]
211 #[pyo3(name = "BUYER")]
212 fn py_buyer() -> Self {
213 Self::Buyer
214 }
215
216 #[classattr]
217 #[pyo3(name = "SELLER")]
218 fn py_seller() -> Self {
219 Self::Seller
220 }
221}
222
223#[pymethods]
224impl AssetClass {
225 #[new]
226 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
227 let t = Self::type_object(py);
228 Self::py_from_str(&t, value)
229 }
230
231 fn __repr__(&self) -> String {
232 format!(
233 "<{}.{}: '{}'>",
234 stringify!(AssetClass),
235 self.name(),
236 self.value(),
237 )
238 }
239
240 fn __str__(&self) -> String {
241 self.to_string()
242 }
243
244 #[getter]
245 #[must_use]
246 pub fn name(&self) -> String {
247 self.to_string()
248 }
249
250 #[getter]
251 #[must_use]
252 pub fn value(&self) -> u8 {
253 *self as u8
254 }
255
256 #[classmethod]
257 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
258 EnumIterator::new::<Self>(py)
259 }
260
261 #[classmethod]
262 #[pyo3(name = "from_str")]
263 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
264 let data_str: &str = data.extract()?;
265 let tokenized = data_str.to_uppercase();
266 Self::from_str(&tokenized).map_err(to_pyvalue_err)
267 }
268
269 #[classattr]
270 #[pyo3(name = "FX")]
271 fn py_fx() -> Self {
272 Self::FX
273 }
274
275 #[classattr]
276 #[pyo3(name = "EQUITY")]
277 fn py_equity() -> Self {
278 Self::Equity
279 }
280
281 #[classattr]
282 #[pyo3(name = "COMMODITY")]
283 fn py_commodity() -> Self {
284 Self::Commodity
285 }
286
287 #[classattr]
288 #[pyo3(name = "DEBT")]
289 fn py_debt() -> Self {
290 Self::Debt
291 }
292
293 #[classattr]
294 #[pyo3(name = "INDEX")]
295 fn py_index() -> Self {
296 Self::Index
297 }
298
299 #[classattr]
300 #[pyo3(name = "CRYPTOCURRENCY")]
301 fn py_cryptocurrency() -> Self {
302 Self::Cryptocurrency
303 }
304
305 #[classattr]
306 #[pyo3(name = "ALTERNATIVE")]
307 fn py_alternative() -> Self {
308 Self::Alternative
309 }
310}
311
312#[pymethods]
313impl InstrumentClass {
314 #[new]
315 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
316 let t = Self::type_object(py);
317 Self::py_from_str(&t, value)
318 }
319
320 fn __repr__(&self) -> String {
321 format!(
322 "<{}.{}: '{}'>",
323 stringify!(InstrumentClass),
324 self.name(),
325 self.value(),
326 )
327 }
328
329 fn __str__(&self) -> String {
330 self.to_string()
331 }
332
333 #[getter]
334 #[must_use]
335 pub fn name(&self) -> String {
336 self.to_string()
337 }
338
339 #[getter]
340 #[must_use]
341 pub fn value(&self) -> u8 {
342 *self as u8
343 }
344
345 #[classmethod]
346 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
347 EnumIterator::new::<Self>(py)
348 }
349
350 #[classmethod]
351 #[pyo3(name = "from_str")]
352 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
353 let data_str: &str = data.extract()?;
354 let tokenized = data_str.to_uppercase();
355 Self::from_str(&tokenized).map_err(to_pyvalue_err)
356 }
357
358 #[classattr]
359 #[pyo3(name = "SPOT")]
360 fn py_spot() -> Self {
361 Self::Spot
362 }
363
364 #[classattr]
365 #[pyo3(name = "SWAP")]
366 fn py_swap() -> Self {
367 Self::Swap
368 }
369
370 #[classattr]
371 #[pyo3(name = "FUTURE")]
372 fn py_future() -> Self {
373 Self::Future
374 }
375
376 #[classattr]
377 #[pyo3(name = "FORWARD")]
378 fn py_forward() -> Self {
379 Self::Forward
380 }
381
382 #[classattr]
383 #[pyo3(name = "CFD")]
384 fn py_cfd() -> Self {
385 Self::Cfd
386 }
387
388 #[classattr]
389 #[pyo3(name = "BOND")]
390 fn py_bond() -> Self {
391 Self::Bond
392 }
393
394 #[classattr]
395 #[pyo3(name = "OPTION")]
396 fn py_option() -> Self {
397 Self::Option
398 }
399
400 #[classattr]
401 #[pyo3(name = "WARRANT")]
402 fn py_warrant() -> Self {
403 Self::Warrant
404 }
405
406 #[classattr]
407 #[pyo3(name = "SPORTS_BETTING")]
408 fn py_sports_betting() -> Self {
409 Self::SportsBetting
410 }
411}
412
413#[pymethods]
414impl BarAggregation {
415 #[new]
416 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
417 let t = Self::type_object(py);
418 Self::py_from_str(&t, value)
419 }
420
421 fn __repr__(&self) -> String {
422 format!(
423 "<{}.{}: '{}'>",
424 stringify!(BarAggregation),
425 self.name(),
426 self.value(),
427 )
428 }
429
430 fn __str__(&self) -> String {
431 self.to_string()
432 }
433
434 #[getter]
435 #[must_use]
436 pub fn name(&self) -> String {
437 self.to_string()
438 }
439
440 #[getter]
441 #[must_use]
442 pub fn value(&self) -> u8 {
443 *self as u8
444 }
445
446 #[classmethod]
447 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
448 EnumIterator::new::<Self>(py)
449 }
450
451 #[classmethod]
452 #[pyo3(name = "from_str")]
453 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
454 let data_str: &str = data.extract()?;
455 let tokenized = data_str.to_uppercase();
456 Self::from_str(&tokenized).map_err(to_pyvalue_err)
457 }
458 #[classattr]
459 #[pyo3(name = "TICK")]
460 fn py_tick() -> Self {
461 Self::Tick
462 }
463
464 #[classattr]
465 #[pyo3(name = "TICK_IMBALANCE")]
466 fn py_tick_imbalance() -> Self {
467 Self::TickImbalance
468 }
469
470 #[classattr]
471 #[pyo3(name = "TICK_RUNS")]
472 fn py_tick_runs() -> Self {
473 Self::TickRuns
474 }
475
476 #[classattr]
477 #[pyo3(name = "VOLUME")]
478 fn py_volume() -> Self {
479 Self::Volume
480 }
481
482 #[classattr]
483 #[pyo3(name = "VOLUME_IMBALANCE")]
484 fn py_volume_imbalance() -> Self {
485 Self::VolumeImbalance
486 }
487
488 #[classattr]
489 #[pyo3(name = "VOLUME_RUNS")]
490 fn py_volume_runs() -> Self {
491 Self::VolumeRuns
492 }
493
494 #[classattr]
495 #[pyo3(name = "VALUE")]
496 fn py_value() -> Self {
497 Self::Value
498 }
499
500 #[classattr]
501 #[pyo3(name = "VALUE_IMBALANCE")]
502 fn py_value_imbalance() -> Self {
503 Self::ValueImbalance
504 }
505
506 #[classattr]
507 #[pyo3(name = "VALUE_RUNS")]
508 fn py_value_runs() -> Self {
509 Self::ValueRuns
510 }
511
512 #[classattr]
513 #[pyo3(name = "MILLISECOND")]
514 fn py_millisecond() -> Self {
515 Self::Millisecond
516 }
517
518 #[classattr]
519 #[pyo3(name = "SECOND")]
520 fn py_second() -> Self {
521 Self::Second
522 }
523
524 #[classattr]
525 #[pyo3(name = "MINUTE")]
526 fn py_minute() -> Self {
527 Self::Minute
528 }
529
530 #[classattr]
531 #[pyo3(name = "HOUR")]
532 fn py_hour() -> Self {
533 Self::Hour
534 }
535
536 #[classattr]
537 #[pyo3(name = "DAY")]
538 fn py_day() -> Self {
539 Self::Day
540 }
541
542 #[classattr]
543 #[pyo3(name = "WEEK")]
544 fn py_week() -> Self {
545 Self::Week
546 }
547
548 #[classattr]
549 #[pyo3(name = "MONTH")]
550 fn py_month() -> Self {
551 Self::Month
552 }
553}
554
555#[pymethods]
556impl BetSide {
557 #[new]
558 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
559 let t = Self::type_object(py);
560 Self::py_from_str(&t, value)
561 }
562
563 fn __repr__(&self) -> String {
564 format!(
565 "<{}.{}: '{}'>",
566 stringify!(BetSide),
567 self.name(),
568 self.value(),
569 )
570 }
571
572 fn __str__(&self) -> String {
573 self.to_string()
574 }
575
576 #[getter]
577 #[must_use]
578 pub fn name(&self) -> String {
579 self.to_string()
580 }
581
582 #[getter]
583 #[must_use]
584 pub fn value(&self) -> u8 {
585 *self as u8
586 }
587
588 #[classmethod]
589 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
590 EnumIterator::new::<Self>(py)
591 }
592
593 #[classmethod]
594 #[pyo3(name = "from_str")]
595 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
596 let data_str: &str = data.extract()?;
597 let tokenized = data_str.to_uppercase();
598 Self::from_str(&tokenized).map_err(to_pyvalue_err)
599 }
600
601 #[classmethod]
602 #[pyo3(name = "from_order_side")]
603 fn py_from_order_side(_: &Bound<'_, PyType>, order_side: OrderSide) -> Self {
604 order_side.into()
605 }
606
607 #[classattr]
608 #[pyo3(name = "BACK")]
609 fn py_back() -> Self {
610 Self::Back
611 }
612
613 #[classattr]
614 #[pyo3(name = "LAY")]
615 fn py_lay() -> Self {
616 Self::Lay
617 }
618
619 #[pyo3(name = "opposite")]
620 fn py_opposite(&self) -> Self {
621 self.opposite()
622 }
623}
624
625#[pymethods]
626impl BookAction {
627 #[new]
628 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
629 let t = Self::type_object(py);
630 Self::py_from_str(&t, value)
631 }
632
633 fn __repr__(&self) -> String {
634 format!(
635 "<{}.{}: '{}'>",
636 stringify!(BookAction),
637 self.name(),
638 self.value(),
639 )
640 }
641
642 fn __str__(&self) -> String {
643 self.to_string()
644 }
645
646 #[getter]
647 #[must_use]
648 pub fn name(&self) -> String {
649 self.to_string()
650 }
651
652 #[getter]
653 #[must_use]
654 pub fn value(&self) -> u8 {
655 *self as u8
656 }
657
658 #[classmethod]
659 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
660 EnumIterator::new::<Self>(py)
661 }
662
663 #[classmethod]
664 #[pyo3(name = "from_str")]
665 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
666 let data_str: &str = data.extract()?;
667 let tokenized = data_str.to_uppercase();
668 Self::from_str(&tokenized).map_err(to_pyvalue_err)
669 }
670
671 #[classattr]
672 #[pyo3(name = "ADD")]
673 fn py_add() -> Self {
674 Self::Add
675 }
676
677 #[classattr]
678 #[pyo3(name = "UPDATE")]
679 fn py_update() -> Self {
680 Self::Update
681 }
682
683 #[classattr]
684 #[pyo3(name = "DELETE")]
685 fn py_delete() -> Self {
686 Self::Delete
687 }
688
689 #[classattr]
690 #[pyo3(name = "CLEAR")]
691 fn py_clear() -> Self {
692 Self::Clear
693 }
694}
695
696#[pymethods]
697impl ContingencyType {
698 #[new]
699 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
700 let t = Self::type_object(py);
701 Self::py_from_str(&t, value)
702 }
703
704 fn __repr__(&self) -> String {
705 format!(
706 "<{}.{}: '{}'>",
707 stringify!(ContingencyType),
708 self.name(),
709 self.value(),
710 )
711 }
712
713 fn __str__(&self) -> String {
714 self.to_string()
715 }
716
717 #[getter]
718 #[must_use]
719 pub fn name(&self) -> String {
720 self.to_string()
721 }
722
723 #[getter]
724 #[must_use]
725 pub fn value(&self) -> u8 {
726 *self as u8
727 }
728
729 #[classmethod]
730 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
731 EnumIterator::new::<Self>(py)
732 }
733
734 #[classmethod]
735 #[pyo3(name = "from_str")]
736 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
737 let data_str: &str = data.extract()?;
738 let tokenized = data_str.to_uppercase();
739 Self::from_str(&tokenized).map_err(to_pyvalue_err)
740 }
741
742 #[classattr]
743 #[pyo3(name = "NO_CONTINGENCY")]
744 fn py_no_contingency() -> Self {
745 Self::NoContingency
746 }
747
748 #[classattr]
749 #[pyo3(name = "OCO")]
750 fn py_oco() -> Self {
751 Self::Oco
752 }
753
754 #[classattr]
755 #[pyo3(name = "OTO")]
756 fn py_oto() -> Self {
757 Self::Oto
758 }
759
760 #[classattr]
761 #[pyo3(name = "OUO")]
762 fn py_ouo() -> Self {
763 Self::Ouo
764 }
765}
766
767#[pymethods]
768impl CurrencyType {
769 #[new]
770 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
771 let t = Self::type_object(py);
772 Self::py_from_str(&t, value)
773 }
774
775 fn __repr__(&self) -> String {
776 format!(
777 "<{}.{}: '{}'>",
778 stringify!(CurrencyType),
779 self.name(),
780 self.value(),
781 )
782 }
783
784 fn __str__(&self) -> String {
785 self.to_string()
786 }
787
788 #[getter]
789 #[must_use]
790 pub fn name(&self) -> String {
791 self.to_string()
792 }
793
794 #[getter]
795 #[must_use]
796 pub fn value(&self) -> u8 {
797 *self as u8
798 }
799
800 #[classmethod]
801 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
802 EnumIterator::new::<Self>(py)
803 }
804
805 #[classmethod]
806 #[pyo3(name = "from_str")]
807 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
808 let data_str: &str = data.extract()?;
809 let tokenized = data_str.to_uppercase();
810 Self::from_str(&tokenized).map_err(to_pyvalue_err)
811 }
812
813 #[classattr]
814 #[pyo3(name = "CRYPTO")]
815 fn py_crypto() -> Self {
816 Self::Crypto
817 }
818
819 #[classattr]
820 #[pyo3(name = "FIAT")]
821 fn py_fiat() -> Self {
822 Self::Fiat
823 }
824
825 #[classattr]
826 #[pyo3(name = "COMMODITY_BACKED")]
827 fn py_commodity_backed() -> Self {
828 Self::CommodityBacked
829 }
830}
831
832#[pymethods]
833impl InstrumentCloseType {
834 #[new]
835 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
836 let t = Self::type_object(py);
837 Self::py_from_str(&t, value)
838 }
839
840 fn __repr__(&self) -> String {
841 format!(
842 "<{}.{}: '{}'>",
843 stringify!(InstrumentCloseType),
844 self.name(),
845 self.value(),
846 )
847 }
848
849 fn __str__(&self) -> String {
850 self.to_string()
851 }
852
853 #[getter]
854 #[must_use]
855 pub fn name(&self) -> String {
856 self.to_string()
857 }
858
859 #[getter]
860 #[must_use]
861 pub fn value(&self) -> u8 {
862 *self as u8
863 }
864
865 #[classmethod]
866 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
867 EnumIterator::new::<Self>(py)
868 }
869
870 #[classmethod]
871 #[pyo3(name = "from_str")]
872 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
873 let data_str: &str = data.extract()?;
874 let tokenized = data_str.to_uppercase();
875 Self::from_str(&tokenized).map_err(to_pyvalue_err)
876 }
877
878 #[classattr]
879 #[pyo3(name = "END_OF_SESSION")]
880 fn py_end_of_session() -> Self {
881 Self::EndOfSession
882 }
883
884 #[classattr]
885 #[pyo3(name = "CONTRACT_EXPIRED")]
886 fn py_contract_expired() -> Self {
887 Self::ContractExpired
888 }
889}
890
891#[pymethods]
892impl LiquiditySide {
893 #[new]
894 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
895 let t = Self::type_object(py);
896 Self::py_from_str(&t, value)
897 }
898
899 fn __repr__(&self) -> String {
900 format!(
901 "<{}.{}: '{}'>",
902 stringify!(LiquiditySide),
903 self.name(),
904 self.value(),
905 )
906 }
907
908 fn __str__(&self) -> String {
909 self.to_string()
910 }
911
912 #[getter]
913 #[must_use]
914 pub fn name(&self) -> String {
915 self.to_string()
916 }
917
918 #[getter]
919 #[must_use]
920 pub fn value(&self) -> u8 {
921 *self as u8
922 }
923
924 #[classmethod]
925 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
926 EnumIterator::new::<Self>(py)
927 }
928
929 #[classmethod]
930 #[pyo3(name = "from_str")]
931 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
932 let data_str: &str = data.extract()?;
933 let tokenized = data_str.to_uppercase();
934 Self::from_str(&tokenized).map_err(to_pyvalue_err)
935 }
936
937 #[classattr]
938 #[pyo3(name = "NO_LIQUIDITY_SIDE")]
939 fn py_no_liquidity_side() -> Self {
940 Self::NoLiquiditySide
941 }
942
943 #[classattr]
944 #[pyo3(name = "MAKER")]
945 fn py_maker() -> Self {
946 Self::Maker
947 }
948
949 #[classattr]
950 #[pyo3(name = "TAKER")]
951 fn py_taker() -> Self {
952 Self::Taker
953 }
954}
955
956#[pymethods]
957impl MarketStatus {
958 #[new]
959 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
960 let t = Self::type_object(py);
961 Self::py_from_str(&t, value)
962 }
963
964 fn __repr__(&self) -> String {
965 format!(
966 "<{}.{}: '{}'>",
967 stringify!(MarketStatus),
968 self.name(),
969 self.value(),
970 )
971 }
972
973 fn __str__(&self) -> String {
974 self.to_string()
975 }
976
977 #[getter]
978 #[must_use]
979 pub fn name(&self) -> String {
980 self.to_string()
981 }
982
983 #[getter]
984 #[must_use]
985 pub fn value(&self) -> u8 {
986 *self as u8
987 }
988
989 #[classmethod]
990 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
991 EnumIterator::new::<Self>(py)
992 }
993
994 #[classmethod]
995 #[pyo3(name = "from_str")]
996 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
997 let data_str: &str = data.extract()?;
998 let tokenized = data_str.to_uppercase();
999 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1000 }
1001
1002 #[classattr]
1003 #[pyo3(name = "Open")]
1004 fn py_open() -> Self {
1005 Self::Open
1006 }
1007
1008 #[classattr]
1009 #[pyo3(name = "CLOSED")]
1010 fn py_closed() -> Self {
1011 Self::Closed
1012 }
1013
1014 #[classattr]
1015 #[pyo3(name = "PAUSED")]
1016 fn py_paused() -> Self {
1017 Self::Paused
1018 }
1019
1020 #[classattr]
1028 #[pyo3(name = "SUSPENDED")]
1029 fn py_suspended() -> Self {
1030 Self::Suspended
1031 }
1032
1033 #[classattr]
1034 #[pyo3(name = "NOT_AVAILABLE")]
1035 fn py_not_available() -> Self {
1036 Self::NotAvailable
1037 }
1038}
1039
1040#[pymethods]
1041impl MarketStatusAction {
1042 #[new]
1043 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1044 let t = Self::type_object(py);
1045 Self::py_from_str(&t, value)
1046 }
1047
1048 fn __repr__(&self) -> String {
1049 format!(
1050 "<{}.{}: '{}'>",
1051 stringify!(MarketStatus),
1052 self.name(),
1053 self.value(),
1054 )
1055 }
1056
1057 fn __str__(&self) -> String {
1058 self.to_string()
1059 }
1060
1061 #[getter]
1062 #[must_use]
1063 pub fn name(&self) -> String {
1064 self.to_string()
1065 }
1066
1067 #[getter]
1068 #[must_use]
1069 pub fn value(&self) -> u8 {
1070 *self as u8
1071 }
1072
1073 #[classmethod]
1074 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1075 EnumIterator::new::<Self>(py)
1076 }
1077
1078 #[classmethod]
1079 #[pyo3(name = "from_str")]
1080 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1081 let data_str: &str = data.extract()?;
1082 let tokenized = data_str.to_uppercase();
1083 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1084 }
1085
1086 #[classattr]
1087 #[pyo3(name = "NONE")]
1088 fn py_none() -> Self {
1089 Self::None
1090 }
1091
1092 #[classattr]
1093 #[pyo3(name = "PRE_OPEN")]
1094 fn py_pre_open() -> Self {
1095 Self::PreOpen
1096 }
1097
1098 #[classattr]
1099 #[pyo3(name = "PRE_CROSS")]
1100 fn py_pre_cross() -> Self {
1101 Self::Pause
1102 }
1103
1104 #[classattr]
1105 #[pyo3(name = "QUOTING")]
1106 fn py_quoting() -> Self {
1107 Self::Quoting
1108 }
1109
1110 #[classattr]
1111 #[pyo3(name = "CROSS")]
1112 fn py_cross() -> Self {
1113 Self::Cross
1114 }
1115
1116 #[classattr]
1117 #[pyo3(name = "ROTATION")]
1118 fn py_rotation() -> Self {
1119 Self::Rotation
1120 }
1121
1122 #[classattr]
1123 #[pyo3(name = "NEW_PRICE_INDICATION")]
1124 fn py_new_price_indication() -> Self {
1125 Self::NewPriceIndication
1126 }
1127
1128 #[classattr]
1129 #[pyo3(name = "TRADING")]
1130 fn py_trading() -> Self {
1131 Self::Trading
1132 }
1133
1134 #[classattr]
1135 #[pyo3(name = "HALT")]
1136 fn py_halt() -> Self {
1137 Self::Halt
1138 }
1139
1140 #[classattr]
1141 #[pyo3(name = "PAUSE")]
1142 fn py_pause() -> Self {
1143 Self::Pause
1144 }
1145
1146 #[classattr]
1147 #[pyo3(name = "SUSPEND")]
1148 fn py_suspend() -> Self {
1149 Self::Suspend
1150 }
1151
1152 #[classattr]
1153 #[pyo3(name = "PRE_CLOSE")]
1154 fn py_pre_close() -> Self {
1155 Self::PreClose
1156 }
1157
1158 #[classattr]
1159 #[pyo3(name = "CLOSE")]
1160 fn py_close() -> Self {
1161 Self::Close
1162 }
1163
1164 #[classattr]
1165 #[pyo3(name = "POST_CLOSE")]
1166 fn py_post_close() -> Self {
1167 Self::PostClose
1168 }
1169
1170 #[classattr]
1171 #[pyo3(name = "SHORT_SELL_RESTRICTION_CHANGE")]
1172 fn py_short_sell_restriction() -> Self {
1173 Self::ShortSellRestrictionChange
1174 }
1175
1176 #[classattr]
1177 #[pyo3(name = "NOT_AVAILABLE_FOR_TRADING")]
1178 fn py_not_available_for_trading() -> Self {
1179 Self::NotAvailableForTrading
1180 }
1181}
1182
1183#[pymethods]
1184impl OmsType {
1185 #[new]
1186 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1187 let t = Self::type_object(py);
1188 Self::py_from_str(&t, value)
1189 }
1190
1191 fn __repr__(&self) -> String {
1192 format!(
1193 "<{}.{}: '{}'>",
1194 stringify!(OmsType),
1195 self.name(),
1196 self.value(),
1197 )
1198 }
1199
1200 fn __str__(&self) -> String {
1201 self.to_string()
1202 }
1203
1204 #[getter]
1205 #[must_use]
1206 pub fn name(&self) -> String {
1207 self.to_string()
1208 }
1209
1210 #[getter]
1211 #[must_use]
1212 pub fn value(&self) -> u8 {
1213 *self as u8
1214 }
1215
1216 #[classmethod]
1217 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1218 EnumIterator::new::<Self>(py)
1219 }
1220
1221 #[classmethod]
1222 #[pyo3(name = "from_str")]
1223 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1224 let data_str: &str = data.extract()?;
1225 let tokenized = data_str.to_uppercase();
1226 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1227 }
1228
1229 #[classattr]
1230 #[pyo3(name = "UNSPECIFIED")]
1231 fn py_unspecified() -> Self {
1232 Self::Unspecified
1233 }
1234
1235 #[classattr]
1236 #[pyo3(name = "NETTING")]
1237 fn py_netting() -> Self {
1238 Self::Netting
1239 }
1240
1241 #[classattr]
1242 #[pyo3(name = "HEDGING")]
1243 fn py_hedging() -> Self {
1244 Self::Hedging
1245 }
1246}
1247
1248#[pymethods]
1249impl OptionKind {
1250 #[new]
1251 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1252 let t = Self::type_object(py);
1253 Self::py_from_str(&t, value)
1254 }
1255
1256 fn __repr__(&self) -> String {
1257 format!(
1258 "<{}.{}: '{}'>",
1259 stringify!(OptionKind),
1260 self.name(),
1261 self.value(),
1262 )
1263 }
1264
1265 fn __str__(&self) -> String {
1266 self.to_string()
1267 }
1268
1269 #[getter]
1270 #[must_use]
1271 pub fn name(&self) -> String {
1272 self.to_string()
1273 }
1274
1275 #[getter]
1276 #[must_use]
1277 pub fn value(&self) -> u8 {
1278 *self as u8
1279 }
1280
1281 #[classmethod]
1282 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1283 EnumIterator::new::<Self>(py)
1284 }
1285
1286 #[classmethod]
1287 #[pyo3(name = "from_str")]
1288 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1289 let data_str: &str = data.extract()?;
1290 let tokenized = data_str.to_uppercase();
1291 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1292 }
1293
1294 #[classattr]
1295 #[pyo3(name = "CALL")]
1296 fn py_call() -> Self {
1297 Self::Call
1298 }
1299
1300 #[classattr]
1301 #[pyo3(name = "PUT")]
1302 fn py_put() -> Self {
1303 Self::Put
1304 }
1305}
1306
1307#[pymethods]
1308impl OrderSide {
1309 #[new]
1310 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1311 let t = Self::type_object(py);
1312 Self::py_from_str(&t, value)
1313 }
1314
1315 fn __repr__(&self) -> String {
1316 format!(
1317 "<{}.{}: '{}'>",
1318 stringify!(OrderSide),
1319 self.name(),
1320 self.value(),
1321 )
1322 }
1323
1324 fn __str__(&self) -> String {
1325 self.to_string()
1326 }
1327
1328 #[getter]
1329 #[must_use]
1330 pub fn name(&self) -> String {
1331 self.to_string()
1332 }
1333
1334 #[getter]
1335 #[must_use]
1336 pub fn value(&self) -> u8 {
1337 *self as u8
1338 }
1339
1340 #[classmethod]
1341 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1342 EnumIterator::new::<Self>(py)
1343 }
1344
1345 #[classmethod]
1346 #[pyo3(name = "from_str")]
1347 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1348 let data_str: &str = data.extract()?;
1349 let tokenized = data_str.to_uppercase();
1350 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1351 }
1352
1353 #[classattr]
1354 #[pyo3(name = "NO_ORDER_SIDE")]
1355 fn py_no_order_side() -> Self {
1356 Self::NoOrderSide
1357 }
1358
1359 #[classattr]
1360 #[pyo3(name = "BUY")]
1361 fn py_buy() -> Self {
1362 Self::Buy
1363 }
1364
1365 #[classattr]
1366 #[pyo3(name = "SELL")]
1367 fn py_sell() -> Self {
1368 Self::Sell
1369 }
1370}
1371
1372#[pymethods]
1373impl OrderStatus {
1374 #[new]
1375 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1376 let t = Self::type_object(py);
1377 Self::py_from_str(&t, value)
1378 }
1379
1380 fn __repr__(&self) -> String {
1381 format!(
1382 "<{}.{}: '{}'>",
1383 stringify!(OrderStatus),
1384 self.name(),
1385 self.value(),
1386 )
1387 }
1388
1389 fn __str__(&self) -> String {
1390 self.to_string()
1391 }
1392
1393 #[getter]
1394 #[must_use]
1395 pub fn name(&self) -> String {
1396 self.to_string()
1397 }
1398
1399 #[getter]
1400 #[must_use]
1401 pub fn value(&self) -> u8 {
1402 *self as u8
1403 }
1404
1405 #[classmethod]
1406 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1407 EnumIterator::new::<Self>(py)
1408 }
1409
1410 #[classmethod]
1411 #[pyo3(name = "from_str")]
1412 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1413 let data_str: &str = data.extract()?;
1414 let tokenized = data_str.to_uppercase();
1415 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1416 }
1417
1418 #[classattr]
1419 #[pyo3(name = "INITIALIZED")]
1420 fn py_initialized() -> Self {
1421 Self::Initialized
1422 }
1423
1424 #[classattr]
1425 #[pyo3(name = "DENIED")]
1426 fn py_denied() -> Self {
1427 Self::Denied
1428 }
1429
1430 #[classattr]
1431 #[pyo3(name = "EMULATED")]
1432 fn py_emulated() -> Self {
1433 Self::Emulated
1434 }
1435
1436 #[classattr]
1437 #[pyo3(name = "RELEASED")]
1438 fn py_released() -> Self {
1439 Self::Released
1440 }
1441
1442 #[classattr]
1443 #[pyo3(name = "SUBMITTED")]
1444 fn py_submitted() -> Self {
1445 Self::Submitted
1446 }
1447
1448 #[classattr]
1449 #[pyo3(name = "ACCEPTED")]
1450 fn py_accepted() -> Self {
1451 Self::Accepted
1452 }
1453
1454 #[classattr]
1455 #[pyo3(name = "REJECTED")]
1456 fn py_rejected() -> Self {
1457 Self::Rejected
1458 }
1459
1460 #[classattr]
1461 #[pyo3(name = "CANCELED")]
1462 fn py_canceled() -> Self {
1463 Self::Canceled
1464 }
1465
1466 #[classattr]
1467 #[pyo3(name = "EXPIRED")]
1468 fn py_expired() -> Self {
1469 Self::Expired
1470 }
1471
1472 #[classattr]
1473 #[pyo3(name = "TRIGGERED")]
1474 fn py_triggered() -> Self {
1475 Self::Triggered
1476 }
1477
1478 #[classattr]
1479 #[pyo3(name = "PENDING_UPDATE")]
1480 fn py_pending_update() -> Self {
1481 Self::PendingUpdate
1482 }
1483
1484 #[classattr]
1485 #[pyo3(name = "PENDING_CANCEL")]
1486 fn py_pending_cancel() -> Self {
1487 Self::PendingCancel
1488 }
1489
1490 #[classattr]
1491 #[pyo3(name = "PARTIALLY_FILLED")]
1492 fn py_partially_filled() -> Self {
1493 Self::PartiallyFilled
1494 }
1495
1496 #[classattr]
1497 #[pyo3(name = "FILLED")]
1498 fn py_filled() -> Self {
1499 Self::Filled
1500 }
1501}
1502
1503#[pymethods]
1504impl OrderType {
1505 #[new]
1506 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1507 let t = Self::type_object(py);
1508 Self::py_from_str(&t, value)
1509 }
1510
1511 fn __repr__(&self) -> String {
1512 format!(
1513 "<{}.{}: '{}'>",
1514 stringify!(OrderType),
1515 self.name(),
1516 self.value(),
1517 )
1518 }
1519
1520 fn __str__(&self) -> String {
1521 self.to_string()
1522 }
1523
1524 #[getter]
1525 #[must_use]
1526 pub fn name(&self) -> String {
1527 self.to_string()
1528 }
1529
1530 #[getter]
1531 #[must_use]
1532 pub fn value(&self) -> u8 {
1533 *self as u8
1534 }
1535
1536 #[classmethod]
1537 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1538 EnumIterator::new::<Self>(py)
1539 }
1540
1541 #[classmethod]
1542 #[pyo3(name = "from_str")]
1543 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1544 let data_str: &str = data.extract()?;
1545 let tokenized = data_str.to_uppercase();
1546 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1547 }
1548
1549 #[classattr]
1550 #[pyo3(name = "MARKET")]
1551 fn py_market() -> Self {
1552 Self::Market
1553 }
1554
1555 #[classattr]
1556 #[pyo3(name = "LIMIT")]
1557 fn py_limit() -> Self {
1558 Self::Limit
1559 }
1560
1561 #[classattr]
1562 #[pyo3(name = "STOP_MARKET")]
1563 fn py_stop_market() -> Self {
1564 Self::StopMarket
1565 }
1566
1567 #[classattr]
1568 #[pyo3(name = "STOP_LIMIT")]
1569 fn py_stop_limit() -> Self {
1570 Self::StopLimit
1571 }
1572
1573 #[classattr]
1574 #[pyo3(name = "MARKET_TO_LIMIT")]
1575 fn py_market_to_limit() -> Self {
1576 Self::MarketToLimit
1577 }
1578
1579 #[classattr]
1580 #[pyo3(name = "MARKET_IF_TOUCHED")]
1581 fn py_market_if_touched() -> Self {
1582 Self::MarketIfTouched
1583 }
1584
1585 #[classattr]
1586 #[pyo3(name = "LIMIT_IF_TOUCHED")]
1587 fn py_limit_if_touched() -> Self {
1588 Self::LimitIfTouched
1589 }
1590
1591 #[classattr]
1592 #[pyo3(name = "TRAILING_STOP_MARKET")]
1593 fn py_trailing_stop_market() -> Self {
1594 Self::TrailingStopMarket
1595 }
1596
1597 #[classattr]
1598 #[pyo3(name = "TRAILING_STOP_LIMIT")]
1599 fn py_trailing_stop_limit() -> Self {
1600 Self::TrailingStopLimit
1601 }
1602}
1603
1604#[pymethods]
1605impl PositionSide {
1606 #[new]
1607 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1608 let t = Self::type_object(py);
1609 Self::py_from_str(&t, value)
1610 }
1611
1612 fn __repr__(&self) -> String {
1613 format!(
1614 "<{}.{}: '{}'>",
1615 stringify!(PositionSide),
1616 self.name(),
1617 self.value(),
1618 )
1619 }
1620
1621 fn __str__(&self) -> String {
1622 self.to_string()
1623 }
1624
1625 #[getter]
1626 #[must_use]
1627 pub fn name(&self) -> String {
1628 self.to_string()
1629 }
1630
1631 #[getter]
1632 #[must_use]
1633 pub fn value(&self) -> u8 {
1634 *self as u8
1635 }
1636
1637 #[classmethod]
1638 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1639 EnumIterator::new::<Self>(py)
1640 }
1641
1642 #[classmethod]
1643 #[pyo3(name = "from_str")]
1644 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1645 let data_str: &str = data.extract()?;
1646 let tokenized = data_str.to_uppercase();
1647 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1648 }
1649
1650 #[classattr]
1651 #[pyo3(name = "NO_POSITION_SIDE")]
1652 fn py_no_position_side() -> Self {
1653 Self::NoPositionSide
1654 }
1655
1656 #[classattr]
1657 #[pyo3(name = "FLAT")]
1658 fn py_flat() -> Self {
1659 Self::Flat
1660 }
1661
1662 #[classattr]
1663 #[pyo3(name = "LONG")]
1664 fn py_long() -> Self {
1665 Self::Long
1666 }
1667
1668 #[classattr]
1669 #[pyo3(name = "SHORT")]
1670 fn py_short() -> Self {
1671 Self::Short
1672 }
1673}
1674
1675#[pymethods]
1676impl PriceType {
1677 #[new]
1678 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1679 let t = Self::type_object(py);
1680 Self::py_from_str(&t, value)
1681 }
1682
1683 fn __repr__(&self) -> String {
1684 format!(
1685 "<{}.{}: '{}'>",
1686 stringify!(PositionSide),
1687 self.name(),
1688 self.value(),
1689 )
1690 }
1691
1692 fn __str__(&self) -> String {
1693 self.to_string()
1694 }
1695
1696 #[getter]
1697 #[must_use]
1698 pub fn name(&self) -> String {
1699 self.to_string()
1700 }
1701
1702 #[getter]
1703 #[must_use]
1704 pub fn value(&self) -> u8 {
1705 *self as u8
1706 }
1707
1708 #[classmethod]
1709 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1710 EnumIterator::new::<Self>(py)
1711 }
1712
1713 #[classmethod]
1714 #[pyo3(name = "from_str")]
1715 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1716 let data_str: &str = data.extract()?;
1717 let tokenized = data_str.to_uppercase();
1718 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1719 }
1720
1721 #[classmethod]
1722 #[pyo3(name = "from_int")]
1723 fn py_from_int(_: &Bound<'_, PyType>, value: i32) -> PyResult<Self> {
1724 Self::from_repr(value as usize)
1725 .ok_or_else(|| PyValueError::new_err(format!("Invalid PriceType value: {value}")))
1726 }
1727
1728 #[classattr]
1729 #[pyo3(name = "BID")]
1730 fn py_bid() -> Self {
1731 Self::Bid
1732 }
1733
1734 #[classattr]
1735 #[pyo3(name = "ASK")]
1736 fn py_ask() -> Self {
1737 Self::Ask
1738 }
1739
1740 #[classattr]
1741 #[pyo3(name = "MID")]
1742 fn py_mid() -> Self {
1743 Self::Mid
1744 }
1745
1746 #[classattr]
1747 #[pyo3(name = "LAST")]
1748 fn py_last() -> Self {
1749 Self::Last
1750 }
1751
1752 #[classattr]
1753 #[pyo3(name = "MARK")]
1754 fn py_mark() -> Self {
1755 Self::Mark
1756 }
1757}
1758
1759#[pymethods]
1760impl RecordFlag {
1761 #[new]
1762 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1763 let t = Self::type_object(py);
1764 Self::py_from_str(&t, value)
1765 }
1766
1767 fn __repr__(&self) -> String {
1768 format!(
1769 "<{}.{}: '{}'>",
1770 stringify!(RecordFlag),
1771 self.name(),
1772 self.value(),
1773 )
1774 }
1775
1776 fn __str__(&self) -> String {
1777 self.to_string()
1778 }
1779
1780 #[getter]
1781 #[must_use]
1782 pub fn name(&self) -> String {
1783 self.to_string()
1784 }
1785
1786 #[getter]
1787 #[must_use]
1788 pub fn value(&self) -> u8 {
1789 *self as u8
1790 }
1791
1792 #[classmethod]
1793 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1794 EnumIterator::new::<Self>(py)
1795 }
1796
1797 #[classmethod]
1798 #[pyo3(name = "from_str")]
1799 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1800 let data_str: &str = data.extract()?;
1801 let tokenized = data_str.to_uppercase();
1802 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1803 }
1804
1805 #[classattr]
1806 #[pyo3(name = "LAST")]
1807 fn py_last() -> Self {
1808 Self::F_LAST
1809 }
1810
1811 #[classattr]
1812 #[pyo3(name = "TOB")]
1813 fn py_tob() -> Self {
1814 Self::F_TOB
1815 }
1816
1817 #[classattr]
1818 #[pyo3(name = "SNAPSHOT")]
1819 fn py_snapshot() -> Self {
1820 Self::F_SNAPSHOT
1821 }
1822
1823 #[classattr]
1824 #[pyo3(name = "MBP")]
1825 fn py_mbp() -> Self {
1826 Self::F_MBP
1827 }
1828
1829 #[pyo3(name = "matches")]
1830 fn py_matches(&self, value: u8) -> bool {
1831 self.matches(value)
1832 }
1833}
1834
1835#[pymethods]
1836impl TimeInForce {
1837 #[new]
1838 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1839 let t = Self::type_object(py);
1840 Self::py_from_str(&t, value)
1841 }
1842
1843 fn __repr__(&self) -> String {
1844 format!(
1845 "<{}.{}: '{}'>",
1846 stringify!(TimeInForce),
1847 self.name(),
1848 self.value(),
1849 )
1850 }
1851
1852 fn __str__(&self) -> String {
1853 self.to_string()
1854 }
1855
1856 #[getter]
1857 #[must_use]
1858 pub fn name(&self) -> String {
1859 self.to_string()
1860 }
1861
1862 #[getter]
1863 #[must_use]
1864 pub fn value(&self) -> u8 {
1865 *self as u8
1866 }
1867
1868 #[classmethod]
1869 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1870 EnumIterator::new::<Self>(py)
1871 }
1872
1873 #[classmethod]
1874 #[pyo3(name = "from_str")]
1875 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1876 let data_str: &str = data.extract()?;
1877 let tokenized = data_str.to_uppercase();
1878 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1879 }
1880
1881 #[classattr]
1882 #[pyo3(name = "GTC")]
1883 fn py_gtc() -> Self {
1884 Self::Gtc
1885 }
1886
1887 #[classattr]
1888 #[pyo3(name = "IOC")]
1889 fn py_ioc() -> Self {
1890 Self::Ioc
1891 }
1892
1893 #[classattr]
1894 #[pyo3(name = "FOK")]
1895 fn py_fok() -> Self {
1896 Self::Fok
1897 }
1898
1899 #[classattr]
1900 #[pyo3(name = "GTD")]
1901 fn py_gtd() -> Self {
1902 Self::Gtd
1903 }
1904
1905 #[classattr]
1906 #[pyo3(name = "DAY")]
1907 fn py_day() -> Self {
1908 Self::Day
1909 }
1910
1911 #[classattr]
1912 #[pyo3(name = "AT_THE_OPEN")]
1913 fn py_at_the_open() -> Self {
1914 Self::AtTheOpen
1915 }
1916
1917 #[classattr]
1918 #[pyo3(name = "AT_THE_CLOSE")]
1919 fn py_at_the_close() -> Self {
1920 Self::AtTheClose
1921 }
1922}
1923
1924#[pymethods]
1925impl TrailingOffsetType {
1926 #[new]
1927 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1928 let t = Self::type_object(py);
1929 Self::py_from_str(&t, value)
1930 }
1931
1932 fn __repr__(&self) -> String {
1933 format!(
1934 "<{}.{}: '{}'>",
1935 stringify!(TrailingOffsetType),
1936 self.name(),
1937 self.value(),
1938 )
1939 }
1940
1941 fn __str__(&self) -> String {
1942 self.to_string()
1943 }
1944
1945 #[getter]
1946 #[must_use]
1947 pub fn name(&self) -> String {
1948 self.to_string()
1949 }
1950
1951 #[getter]
1952 #[must_use]
1953 pub fn value(&self) -> u8 {
1954 *self as u8
1955 }
1956
1957 #[classmethod]
1958 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1959 EnumIterator::new::<Self>(py)
1960 }
1961
1962 #[classmethod]
1963 #[pyo3(name = "from_str")]
1964 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1965 let data_str: &str = data.extract()?;
1966 let tokenized = data_str.to_uppercase();
1967 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1968 }
1969
1970 #[classattr]
1971 #[pyo3(name = "NO_TRAILING_OFFSET")]
1972 fn py_no_trailing_offset() -> Self {
1973 Self::NoTrailingOffset
1974 }
1975
1976 #[classattr]
1977 #[pyo3(name = "PRICE")]
1978 fn py_price() -> Self {
1979 Self::Price
1980 }
1981
1982 #[classattr]
1983 #[pyo3(name = "BASIS_POINTS")]
1984 fn py_basis_points() -> Self {
1985 Self::BasisPoints
1986 }
1987
1988 #[classattr]
1989 #[pyo3(name = "TICKS")]
1990 fn py_ticks() -> Self {
1991 Self::Ticks
1992 }
1993
1994 #[classattr]
1995 #[pyo3(name = "PRICE_TIER")]
1996 fn py_price_tier() -> Self {
1997 Self::PriceTier
1998 }
1999}
2000
2001#[pymethods]
2002impl TriggerType {
2003 #[new]
2004 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
2005 let t = Self::type_object(py);
2006 Self::py_from_str(&t, value)
2007 }
2008
2009 fn __repr__(&self) -> String {
2010 format!(
2011 "<{}.{}: '{}'>",
2012 stringify!(TriggerType),
2013 self.name(),
2014 self.value(),
2015 )
2016 }
2017
2018 fn __str__(&self) -> String {
2019 self.to_string()
2020 }
2021
2022 #[getter]
2023 #[must_use]
2024 pub fn name(&self) -> String {
2025 self.to_string()
2026 }
2027
2028 #[getter]
2029 #[must_use]
2030 pub fn value(&self) -> u8 {
2031 *self as u8
2032 }
2033
2034 #[classmethod]
2035 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
2036 EnumIterator::new::<Self>(py)
2037 }
2038
2039 #[classmethod]
2040 #[pyo3(name = "from_str")]
2041 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
2042 let data_str: &str = data.extract()?;
2043 let tokenized = data_str.to_uppercase();
2044 Self::from_str(&tokenized).map_err(to_pyvalue_err)
2045 }
2046
2047 #[classattr]
2048 #[pyo3(name = "NO_TRIGGER")]
2049 fn py_no_trigger() -> Self {
2050 Self::NoTrigger
2051 }
2052
2053 #[classattr]
2054 #[pyo3(name = "DEFAULT")]
2055 fn py_default() -> Self {
2056 Self::Default
2057 }
2058
2059 #[classattr]
2060 #[pyo3(name = "BID_ASK")]
2061 fn py_bid_ask() -> Self {
2062 Self::BidAsk
2063 }
2064
2065 #[classattr]
2066 #[pyo3(name = "LAST_PRICE")]
2067 fn py_last_trade() -> Self {
2068 Self::LastPrice
2069 }
2070
2071 #[classattr]
2072 #[pyo3(name = "DOUBLE_LAST")]
2073 fn py_double_last() -> Self {
2074 Self::DoubleLast
2075 }
2076
2077 #[classattr]
2078 #[pyo3(name = "DOUBLE_BID_ASK")]
2079 fn py_double_bid_ask() -> Self {
2080 Self::DoubleBidAsk
2081 }
2082
2083 #[classattr]
2084 #[pyo3(name = "LAST_OR_BID_ASK")]
2085 fn py_last_or_bid_ask() -> Self {
2086 Self::LastOrBidAsk
2087 }
2088
2089 #[classattr]
2090 #[pyo3(name = "MID_POINT")]
2091 fn py_mid_point() -> Self {
2092 Self::MidPoint
2093 }
2094
2095 #[classattr]
2096 #[pyo3(name = "MARK_PRICE")]
2097 fn py_mark_price() -> Self {
2098 Self::MarkPrice
2099 }
2100
2101 #[classattr]
2102 #[pyo3(name = "INDEX_PRICE")]
2103 fn py_index_price() -> Self {
2104 Self::IndexPrice
2105 }
2106}
2107
2108#[pymethods]
2109impl BookType {
2110 #[new]
2111 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
2112 let t = Self::type_object(py);
2113 Self::py_from_str(&t, value)
2114 }
2115
2116 fn __repr__(&self) -> String {
2117 format!(
2118 "<{}.{}: '{}'>",
2119 stringify!(BookType),
2120 self.name(),
2121 self.value(),
2122 )
2123 }
2124
2125 fn __str__(&self) -> String {
2126 self.to_string()
2127 }
2128
2129 #[getter]
2130 #[must_use]
2131 pub fn name(&self) -> String {
2132 self.to_string()
2133 }
2134
2135 #[getter]
2136 #[must_use]
2137 pub fn value(&self) -> u8 {
2138 *self as u8
2139 }
2140
2141 #[classmethod]
2142 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
2143 EnumIterator::new::<Self>(py)
2144 }
2145
2146 #[classmethod]
2147 #[pyo3(name = "from_str")]
2148 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
2149 let data_str: &str = data.extract()?;
2150 let tokenized = data_str.to_uppercase();
2151 Self::from_str(&tokenized).map_err(to_pyvalue_err)
2152 }
2153
2154 #[classattr]
2155 #[pyo3(name = "L1_MBP")]
2156 fn py_l1_mbp() -> Self {
2157 Self::L1_MBP
2158 }
2159
2160 #[classattr]
2161 #[pyo3(name = "L2_MBP")]
2162 fn py_l2_mbp() -> Self {
2163 Self::L2_MBP
2164 }
2165
2166 #[classattr]
2167 #[pyo3(name = "L3_MBO")]
2168 fn py_l3_mbo() -> Self {
2169 Self::L3_MBO
2170 }
2171}
2172
2173#[pymethods]
2174impl TradingState {
2175 #[new]
2176 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
2177 let t = Self::type_object(py);
2178 Self::py_from_str(&t, value)
2179 }
2180
2181 fn __repr__(&self) -> String {
2182 format!(
2183 "<{}.{}: '{}'>",
2184 stringify!(TradingState),
2185 self.name(),
2186 self.value(),
2187 )
2188 }
2189
2190 fn __str__(&self) -> String {
2191 self.to_string()
2192 }
2193
2194 #[getter]
2195 #[must_use]
2196 pub fn name(&self) -> String {
2197 self.to_string()
2198 }
2199
2200 #[getter]
2201 #[must_use]
2202 pub fn value(&self) -> u8 {
2203 *self as u8
2204 }
2205
2206 #[classmethod]
2207 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
2208 EnumIterator::new::<Self>(py)
2209 }
2210
2211 #[classmethod]
2212 #[pyo3(name = "from_str")]
2213 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
2214 let data_str: &str = data.extract()?;
2215 let tokenized = data_str.to_uppercase();
2216 Self::from_str(&tokenized).map_err(to_pyvalue_err)
2217 }
2218
2219 #[classattr]
2220 #[pyo3(name = "ACTIVE")]
2221 fn py_active() -> Self {
2222 Self::Active
2223 }
2224
2225 #[classattr]
2226 #[pyo3(name = "HALTED")]
2227 fn py_halted() -> Self {
2228 Self::Halted
2229 }
2230
2231 #[classattr]
2232 #[pyo3(name = "REDUCING")]
2233 fn py_reducing() -> Self {
2234 Self::Reducing
2235 }
2236}