1use std::str::FromStr;
19
20use nautilus_core::python::to_pyvalue_err;
21use pyo3::{PyTypeInfo, prelude::*, types::PyType};
22
23use crate::{
24 enums::{
25 AccountType, AggregationSource, AggressorSide, AssetClass, BarAggregation, BarIntervalType,
26 BetSide, BookAction, BookType, ContingencyType, ContinuousFutureAdjustmentType,
27 CurrencyType, GreeksConvention, InstrumentClass, InstrumentCloseType, LiquiditySide,
28 MarketStatus, MarketStatusAction, OmsType, OptionKind, OrderSide, OrderStatus, OrderType,
29 OtoTriggerMode, PositionAdjustmentType, PositionSide, PriceType, RecordFlag, TimeInForce,
30 TradingState, TrailingOffsetType, TriggerType,
31 },
32 python::common::EnumIterator,
33};
34
35#[pymethods]
36#[pyo3_stub_gen::derive::gen_stub_pymethods]
37impl AccountType {
38 #[new]
40 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
41 let t = Self::type_object(py);
42 Self::py_from_str(&t, value)
43 }
44
45 const fn __hash__(&self) -> isize {
46 *self as isize
47 }
48
49 fn __str__(&self) -> String {
50 self.to_string()
51 }
52
53 #[getter]
54 #[must_use]
55 pub fn name(&self) -> String {
56 self.to_string()
57 }
58
59 #[getter]
60 #[must_use]
61 pub fn value(&self) -> u8 {
62 *self as u8
63 }
64
65 #[classmethod]
66 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
67 EnumIterator::new::<Self>(py)
68 }
69
70 #[classmethod]
71 #[pyo3(name = "from_str")]
72 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
73 let data_str: &str = data.extract()?;
74 let tokenized = data_str.to_uppercase();
75 Self::from_str(&tokenized).map_err(to_pyvalue_err)
76 }
77}
78
79#[pymethods]
80#[pyo3_stub_gen::derive::gen_stub_pymethods]
81impl PositionAdjustmentType {
82 #[new]
84 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
85 let t = Self::type_object(py);
86 Self::py_from_str(&t, value)
87 }
88
89 const fn __hash__(&self) -> isize {
90 *self as isize
91 }
92
93 fn __str__(&self) -> String {
94 self.to_string()
95 }
96
97 #[getter]
98 #[must_use]
99 pub fn name(&self) -> String {
100 self.to_string()
101 }
102
103 #[getter]
104 #[must_use]
105 pub fn value(&self) -> u8 {
106 *self as u8
107 }
108
109 #[classmethod]
110 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
111 EnumIterator::new::<Self>(py)
112 }
113
114 #[classmethod]
115 #[pyo3(name = "from_str")]
116 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
117 let data_str: &str = data.extract()?;
118 let tokenized = data_str.to_uppercase();
119 Self::from_str(&tokenized).map_err(to_pyvalue_err)
120 }
121}
122
123#[pymethods]
124#[pyo3_stub_gen::derive::gen_stub_pymethods]
125impl AggregationSource {
126 #[new]
128 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
129 let t = Self::type_object(py);
130 Self::py_from_str(&t, value)
131 }
132
133 const fn __hash__(&self) -> isize {
134 *self as isize
135 }
136
137 fn __str__(&self) -> String {
138 self.to_string()
139 }
140
141 #[getter]
142 #[must_use]
143 pub fn name(&self) -> String {
144 self.to_string()
145 }
146
147 #[getter]
148 #[must_use]
149 pub fn value(&self) -> u8 {
150 *self as u8
151 }
152
153 #[classmethod]
154 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
155 EnumIterator::new::<Self>(py)
156 }
157
158 #[classmethod]
159 #[pyo3(name = "from_str")]
160 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
161 let data_str: &str = data.extract()?;
162 let tokenized = data_str.to_uppercase();
163 Self::from_str(&tokenized).map_err(to_pyvalue_err)
164 }
165}
166
167#[pymethods]
168#[pyo3_stub_gen::derive::gen_stub_pymethods]
169impl AggressorSide {
170 #[new]
172 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
173 let t = Self::type_object(py);
174 Self::py_from_str(&t, value)
175 }
176
177 const fn __hash__(&self) -> isize {
178 *self as isize
179 }
180
181 fn __str__(&self) -> String {
182 self.to_string()
183 }
184
185 #[getter]
186 #[must_use]
187 pub fn name(&self) -> String {
188 self.to_string()
189 }
190
191 #[getter]
192 #[must_use]
193 pub fn value(&self) -> u8 {
194 *self as u8
195 }
196
197 #[classmethod]
198 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
199 EnumIterator::new::<Self>(py)
200 }
201
202 #[classmethod]
203 #[pyo3(name = "from_str")]
204 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
205 let data_str: &str = data.extract()?;
206 let tokenized = data_str.to_uppercase();
207 Self::from_str(&tokenized).map_err(to_pyvalue_err)
208 }
209}
210
211#[pymethods]
212#[pyo3_stub_gen::derive::gen_stub_pymethods]
213impl AssetClass {
214 #[new]
216 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
217 let t = Self::type_object(py);
218 Self::py_from_str(&t, value)
219 }
220
221 const fn __hash__(&self) -> isize {
222 *self as isize
223 }
224
225 fn __str__(&self) -> String {
226 self.to_string()
227 }
228
229 #[getter]
230 #[must_use]
231 pub fn name(&self) -> String {
232 self.to_string()
233 }
234
235 #[getter]
236 #[must_use]
237 pub fn value(&self) -> u8 {
238 *self as u8
239 }
240
241 #[classmethod]
242 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
243 EnumIterator::new::<Self>(py)
244 }
245
246 #[classmethod]
247 #[pyo3(name = "from_str")]
248 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
249 let data_str: &str = data.extract()?;
250 let tokenized = data_str.to_uppercase();
251 Self::from_str(&tokenized).map_err(to_pyvalue_err)
252 }
253}
254
255#[pymethods]
256#[pyo3_stub_gen::derive::gen_stub_pymethods]
257impl InstrumentClass {
258 #[new]
260 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
261 let t = Self::type_object(py);
262 Self::py_from_str(&t, value)
263 }
264
265 const fn __hash__(&self) -> isize {
266 *self as isize
267 }
268
269 fn __str__(&self) -> String {
270 self.to_string()
271 }
272
273 #[getter]
274 #[must_use]
275 pub fn name(&self) -> String {
276 self.to_string()
277 }
278
279 #[getter]
280 #[must_use]
281 pub fn value(&self) -> u8 {
282 *self as u8
283 }
284
285 #[classmethod]
286 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
287 EnumIterator::new::<Self>(py)
288 }
289
290 #[classmethod]
291 #[pyo3(name = "from_str")]
292 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
293 let data_str: &str = data.extract()?;
294 let tokenized = data_str.to_uppercase();
295 Self::from_str(&tokenized).map_err(to_pyvalue_err)
296 }
297
298 #[pyo3(name = "has_expiration")]
300 #[must_use]
301 pub const fn py_has_expiration(&self) -> bool {
302 self.has_expiration()
303 }
304
305 #[pyo3(name = "allows_negative_price")]
307 #[must_use]
308 pub const fn py_allows_negative_price(&self) -> bool {
309 self.allows_negative_price()
310 }
311
312 #[pyo3(name = "parent_suffix")]
317 #[must_use]
318 pub const fn py_parent_suffix(&self) -> Option<&'static str> {
319 self.parent_suffix()
320 }
321
322 #[classmethod]
327 #[pyo3(name = "try_from_parent_suffix")]
328 #[must_use]
329 pub fn py_try_from_parent_suffix(_: &Bound<'_, PyType>, suffix: &str) -> Option<Self> {
330 Self::try_from_parent_suffix(suffix)
331 }
332}
333
334#[pymethods]
335#[pyo3_stub_gen::derive::gen_stub_pymethods]
336impl BarAggregation {
337 #[new]
339 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
340 let t = Self::type_object(py);
341 Self::py_from_str(&t, value)
342 }
343
344 const fn __hash__(&self) -> isize {
345 *self as isize
346 }
347
348 fn __str__(&self) -> String {
349 self.to_string()
350 }
351
352 #[getter]
353 #[must_use]
354 pub fn name(&self) -> String {
355 self.to_string()
356 }
357
358 #[getter]
359 #[must_use]
360 pub fn value(&self) -> u8 {
361 *self as u8
362 }
363
364 #[classmethod]
365 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
366 EnumIterator::new::<Self>(py)
367 }
368
369 #[classmethod]
370 #[pyo3(name = "from_str")]
371 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
372 let data_str: &str = data.extract()?;
373 let tokenized = data_str.to_uppercase();
374 Self::from_str(&tokenized).map_err(to_pyvalue_err)
375 }
376}
377
378#[pymethods]
379#[pyo3_stub_gen::derive::gen_stub_pymethods]
380impl BarIntervalType {
381 const fn __hash__(&self) -> isize {
382 *self as isize
383 }
384}
385
386#[pymethods]
387#[pyo3_stub_gen::derive::gen_stub_pymethods]
388impl BetSide {
389 #[new]
391 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
392 let t = Self::type_object(py);
393 Self::py_from_str(&t, value)
394 }
395
396 const fn __hash__(&self) -> isize {
397 *self as isize
398 }
399
400 fn __str__(&self) -> String {
401 self.to_string()
402 }
403
404 #[getter]
405 #[must_use]
406 pub fn name(&self) -> String {
407 self.to_string()
408 }
409
410 #[getter]
411 #[must_use]
412 pub fn value(&self) -> u8 {
413 *self as u8
414 }
415
416 #[classmethod]
417 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
418 EnumIterator::new::<Self>(py)
419 }
420
421 #[classmethod]
422 #[pyo3(name = "from_str")]
423 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
424 let data_str: &str = data.extract()?;
425 let tokenized = data_str.to_uppercase();
426 Self::from_str(&tokenized).map_err(to_pyvalue_err)
427 }
428
429 #[classmethod]
430 #[pyo3(name = "from_order_side")]
431 fn py_from_order_side(_: &Bound<'_, PyType>, order_side: OrderSide) -> Self {
432 order_side.into()
433 }
434
435 #[pyo3(name = "opposite")]
437 fn py_opposite(&self) -> Self {
438 self.opposite()
439 }
440}
441
442#[pymethods]
443#[pyo3_stub_gen::derive::gen_stub_pymethods]
444impl BookAction {
445 #[new]
447 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
448 let t = Self::type_object(py);
449 Self::py_from_str(&t, value)
450 }
451
452 const fn __hash__(&self) -> isize {
453 *self as isize
454 }
455
456 fn __str__(&self) -> String {
457 self.to_string()
458 }
459
460 #[getter]
461 #[must_use]
462 pub fn name(&self) -> String {
463 self.to_string()
464 }
465
466 #[getter]
467 #[must_use]
468 pub fn value(&self) -> u8 {
469 *self as u8
470 }
471
472 #[classmethod]
473 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
474 EnumIterator::new::<Self>(py)
475 }
476
477 #[classmethod]
478 #[pyo3(name = "from_str")]
479 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
480 let data_str: &str = data.extract()?;
481 let tokenized = data_str.to_uppercase();
482 Self::from_str(&tokenized).map_err(to_pyvalue_err)
483 }
484}
485
486#[pyo3_stub_gen::derive::gen_stub_pymethods]
488#[pymethods]
489impl ContingencyType {
490 #[new]
497 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
498 let t = Self::type_object(py);
499 Self::py_from_str(&t, value)
500 }
501
502 #[classattr]
506 #[pyo3(name = "NO_CONTINGENCY")]
507 #[allow(clippy::use_self)]
508 const fn py_no_contingency() -> Option<ContingencyType> {
509 None
510 }
511
512 const fn __hash__(&self) -> isize {
513 *self as isize
514 }
515
516 fn __str__(&self) -> String {
517 self.to_string()
518 }
519
520 #[getter]
521 #[must_use]
522 pub fn name(&self) -> String {
523 self.to_string()
524 }
525
526 #[getter]
527 #[must_use]
528 pub fn value(&self) -> u8 {
529 *self as u8
530 }
531
532 #[classmethod]
533 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
534 EnumIterator::new::<Self>(py)
535 }
536
537 #[classmethod]
538 #[pyo3(name = "from_str")]
539 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
540 let data_str: &str = data.extract()?;
541 let tokenized = data_str.to_uppercase();
542 if tokenized == "NO_CONTINGENCY" {
543 Ok(None)
544 } else {
545 Self::from_str(&tokenized).map(Some).map_err(to_pyvalue_err)
546 }
547 }
548}
549
550#[pymethods]
551#[pyo3_stub_gen::derive::gen_stub_pymethods]
552impl ContinuousFutureAdjustmentType {
553 #[new]
567 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
568 let t = Self::type_object(py);
569 Self::py_from_str(&t, value)
570 }
571
572 const fn __hash__(&self) -> isize {
573 *self as isize
574 }
575
576 fn __str__(&self) -> String {
577 self.to_string()
578 }
579
580 #[getter]
581 #[must_use]
582 pub fn name(&self) -> String {
583 self.to_string()
584 }
585
586 #[getter]
587 #[must_use]
588 pub fn value(&self) -> u8 {
589 *self as u8
590 }
591
592 #[getter(is_ratio)]
594 #[must_use]
595 pub const fn py_is_ratio(&self) -> bool {
596 self.is_ratio()
597 }
598
599 #[getter(is_backward)]
601 #[must_use]
602 pub const fn py_is_backward(&self) -> bool {
603 self.is_backward()
604 }
605
606 #[classmethod]
607 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
608 EnumIterator::new::<Self>(py)
609 }
610
611 #[classmethod]
612 #[pyo3(name = "from_str")]
613 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
614 let data_str: &str = data.extract()?;
615 let tokenized = data_str.to_uppercase();
616 Self::from_str(&tokenized).map_err(to_pyvalue_err)
617 }
618}
619
620#[pymethods]
621#[pyo3_stub_gen::derive::gen_stub_pymethods]
622impl CurrencyType {
623 #[new]
625 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
626 let t = Self::type_object(py);
627 Self::py_from_str(&t, value)
628 }
629
630 const fn __hash__(&self) -> isize {
631 *self as isize
632 }
633
634 fn __str__(&self) -> String {
635 self.to_string()
636 }
637
638 #[getter]
639 #[must_use]
640 pub fn name(&self) -> String {
641 self.to_string()
642 }
643
644 #[getter]
645 #[must_use]
646 pub fn value(&self) -> u8 {
647 *self as u8
648 }
649
650 #[classmethod]
651 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
652 EnumIterator::new::<Self>(py)
653 }
654
655 #[classmethod]
656 #[pyo3(name = "from_str")]
657 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
658 let data_str: &str = data.extract()?;
659 let tokenized = data_str.to_uppercase();
660 Self::from_str(&tokenized).map_err(to_pyvalue_err)
661 }
662}
663
664#[pymethods]
665#[pyo3_stub_gen::derive::gen_stub_pymethods]
666impl InstrumentCloseType {
667 #[new]
669 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
670 let t = Self::type_object(py);
671 Self::py_from_str(&t, value)
672 }
673
674 const fn __hash__(&self) -> isize {
675 *self as isize
676 }
677
678 fn __str__(&self) -> String {
679 self.to_string()
680 }
681
682 #[getter]
683 #[must_use]
684 pub fn name(&self) -> String {
685 self.to_string()
686 }
687
688 #[getter]
689 #[must_use]
690 pub fn value(&self) -> u8 {
691 *self as u8
692 }
693
694 #[classmethod]
695 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
696 EnumIterator::new::<Self>(py)
697 }
698
699 #[classmethod]
700 #[pyo3(name = "from_str")]
701 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
702 let data_str: &str = data.extract()?;
703 let tokenized = data_str.to_uppercase();
704 Self::from_str(&tokenized).map_err(to_pyvalue_err)
705 }
706}
707
708#[pymethods]
709#[pyo3_stub_gen::derive::gen_stub_pymethods]
710impl LiquiditySide {
711 #[new]
713 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
714 let t = Self::type_object(py);
715 Self::py_from_str(&t, value)
716 }
717
718 const fn __hash__(&self) -> isize {
719 *self as isize
720 }
721
722 fn __str__(&self) -> String {
723 self.to_string()
724 }
725
726 #[getter]
727 #[must_use]
728 pub fn name(&self) -> String {
729 self.to_string()
730 }
731
732 #[getter]
733 #[must_use]
734 pub fn value(&self) -> u8 {
735 *self as u8
736 }
737
738 #[classmethod]
739 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
740 EnumIterator::new::<Self>(py)
741 }
742
743 #[classmethod]
744 #[pyo3(name = "from_str")]
745 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
746 let data_str: &str = data.extract()?;
747 let tokenized = data_str.to_uppercase();
748 Self::from_str(&tokenized).map_err(to_pyvalue_err)
749 }
750}
751
752#[pymethods]
753#[pyo3_stub_gen::derive::gen_stub_pymethods]
754impl MarketStatus {
755 #[new]
757 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
758 let t = Self::type_object(py);
759 Self::py_from_str(&t, value)
760 }
761
762 const fn __hash__(&self) -> isize {
763 *self as isize
764 }
765
766 fn __str__(&self) -> String {
767 self.to_string()
768 }
769
770 #[getter]
771 #[must_use]
772 pub fn name(&self) -> String {
773 self.to_string()
774 }
775
776 #[getter]
777 #[must_use]
778 pub fn value(&self) -> u8 {
779 *self as u8
780 }
781
782 #[classmethod]
783 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
784 EnumIterator::new::<Self>(py)
785 }
786
787 #[classmethod]
788 #[pyo3(name = "from_str")]
789 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
790 let data_str: &str = data.extract()?;
791 let tokenized = data_str.to_uppercase();
792 Self::from_str(&tokenized).map_err(to_pyvalue_err)
793 }
794}
795
796#[pymethods]
797#[pyo3_stub_gen::derive::gen_stub_pymethods]
798impl MarketStatusAction {
799 #[new]
801 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
802 let t = Self::type_object(py);
803 Self::py_from_str(&t, value)
804 }
805
806 const fn __hash__(&self) -> isize {
807 *self as isize
808 }
809
810 fn __str__(&self) -> String {
811 self.to_string()
812 }
813
814 #[getter]
815 #[must_use]
816 pub fn name(&self) -> String {
817 self.to_string()
818 }
819
820 #[getter]
821 #[must_use]
822 pub fn value(&self) -> u8 {
823 *self as u8
824 }
825
826 #[classmethod]
827 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
828 EnumIterator::new::<Self>(py)
829 }
830
831 #[classmethod]
832 #[pyo3(name = "from_str")]
833 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
834 let data_str: &str = data.extract()?;
835 let tokenized = data_str.to_uppercase();
836 Self::from_str(&tokenized).map_err(to_pyvalue_err)
837 }
838}
839
840#[pymethods]
841#[pyo3_stub_gen::derive::gen_stub_pymethods]
842impl OmsType {
843 #[new]
845 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
846 let t = Self::type_object(py);
847 Self::py_from_str(&t, value)
848 }
849
850 const fn __hash__(&self) -> isize {
851 *self as isize
852 }
853
854 fn __str__(&self) -> String {
855 self.to_string()
856 }
857
858 #[getter]
859 #[must_use]
860 pub fn name(&self) -> String {
861 self.to_string()
862 }
863
864 #[getter]
865 #[must_use]
866 pub fn value(&self) -> u8 {
867 *self as u8
868 }
869
870 #[classmethod]
871 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
872 EnumIterator::new::<Self>(py)
873 }
874
875 #[classmethod]
876 #[pyo3(name = "from_str")]
877 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
878 let data_str: &str = data.extract()?;
879 let tokenized = data_str.to_uppercase();
880 Self::from_str(&tokenized).map_err(to_pyvalue_err)
881 }
882}
883
884#[pymethods]
885#[pyo3_stub_gen::derive::gen_stub_pymethods]
886impl OptionKind {
887 #[new]
889 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
890 let t = Self::type_object(py);
891 Self::py_from_str(&t, value)
892 }
893
894 const fn __hash__(&self) -> isize {
895 *self as isize
896 }
897
898 fn __str__(&self) -> String {
899 self.to_string()
900 }
901
902 #[getter]
903 #[must_use]
904 pub fn name(&self) -> String {
905 self.to_string()
906 }
907
908 #[getter]
909 #[must_use]
910 pub fn value(&self) -> u8 {
911 *self as u8
912 }
913
914 #[classmethod]
915 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
916 EnumIterator::new::<Self>(py)
917 }
918
919 #[classmethod]
920 #[pyo3(name = "from_str")]
921 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
922 let data_str: &str = data.extract()?;
923 let tokenized = data_str.to_uppercase();
924 Self::from_str(&tokenized).map_err(to_pyvalue_err)
925 }
926}
927
928#[pymethods]
929#[pyo3_stub_gen::derive::gen_stub_pymethods]
930impl GreeksConvention {
931 #[new]
943 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
944 let t = Self::type_object(py);
945 Self::py_from_str(&t, value)
946 }
947
948 const fn __hash__(&self) -> isize {
949 *self as isize
950 }
951
952 fn __str__(&self) -> String {
953 self.to_string()
954 }
955
956 #[getter]
957 #[must_use]
958 pub fn name(&self) -> String {
959 self.to_string()
960 }
961
962 #[getter]
963 #[must_use]
964 pub fn value(&self) -> u8 {
965 *self as u8
966 }
967
968 #[classmethod]
969 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
970 EnumIterator::new::<Self>(py)
971 }
972
973 #[classmethod]
974 #[pyo3(name = "from_str")]
975 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
976 let data_str: &str = data.extract()?;
977 let tokenized = data_str.to_uppercase();
978 Self::from_str(&tokenized).map_err(to_pyvalue_err)
979 }
980}
981
982#[pymethods]
983#[pyo3_stub_gen::derive::gen_stub_pymethods]
984impl OtoTriggerMode {
985 #[new]
987 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
988 let t = Self::type_object(py);
989 Self::py_from_str(&t, value)
990 }
991
992 const fn __hash__(&self) -> isize {
993 *self as isize
994 }
995
996 fn __str__(&self) -> String {
997 self.to_string()
998 }
999
1000 #[getter]
1001 #[must_use]
1002 pub fn name(&self) -> String {
1003 self.to_string()
1004 }
1005
1006 #[getter]
1007 #[must_use]
1008 pub fn value(&self) -> u8 {
1009 *self as u8
1010 }
1011
1012 #[classmethod]
1013 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1014 EnumIterator::new::<Self>(py)
1015 }
1016
1017 #[classmethod]
1018 #[pyo3(name = "from_str")]
1019 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1020 let data_str: &str = data.extract()?;
1021 let tokenized = data_str.to_uppercase();
1022 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1023 }
1024}
1025
1026#[pyo3_stub_gen::derive::gen_stub_pymethods]
1028#[pymethods]
1029impl OrderSide {
1030 #[new]
1035 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
1036 let t = Self::type_object(py);
1037 Self::py_from_str(&t, value)
1038 }
1039
1040 #[classattr]
1044 #[pyo3(name = "NO_ORDER_SIDE")]
1045 #[allow(clippy::use_self)]
1046 const fn py_no_order_side() -> Option<OrderSide> {
1047 None
1048 }
1049
1050 const fn __hash__(&self) -> isize {
1051 *self as isize
1052 }
1053
1054 fn __str__(&self) -> String {
1055 self.to_string()
1056 }
1057
1058 #[getter]
1059 #[must_use]
1060 pub fn name(&self) -> String {
1061 self.to_string()
1062 }
1063
1064 #[getter]
1065 #[must_use]
1066 pub fn value(&self) -> u8 {
1067 *self as u8
1068 }
1069
1070 #[classmethod]
1071 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1072 EnumIterator::new::<Self>(py)
1073 }
1074
1075 #[classmethod]
1076 #[pyo3(name = "from_str")]
1077 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
1078 let data_str: &str = data.extract()?;
1079 let tokenized = data_str.to_uppercase();
1080 if tokenized == "NO_ORDER_SIDE" {
1081 Ok(None)
1082 } else {
1083 Self::from_str(&tokenized).map(Some).map_err(to_pyvalue_err)
1084 }
1085 }
1086}
1087
1088#[pymethods]
1089#[pyo3_stub_gen::derive::gen_stub_pymethods]
1090impl OrderStatus {
1091 #[new]
1113 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1114 let t = Self::type_object(py);
1115 Self::py_from_str(&t, value)
1116 }
1117
1118 const fn __hash__(&self) -> isize {
1119 *self as isize
1120 }
1121
1122 fn __str__(&self) -> String {
1123 self.to_string()
1124 }
1125
1126 #[getter]
1127 #[must_use]
1128 pub fn name(&self) -> String {
1129 self.to_string()
1130 }
1131
1132 #[getter]
1133 #[must_use]
1134 pub fn value(&self) -> u8 {
1135 *self as u8
1136 }
1137
1138 #[classmethod]
1139 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1140 EnumIterator::new::<Self>(py)
1141 }
1142
1143 #[classmethod]
1144 #[pyo3(name = "from_str")]
1145 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1146 let data_str: &str = data.extract()?;
1147 let tokenized = data_str.to_uppercase();
1148 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1149 }
1150}
1151
1152#[pymethods]
1153#[pyo3_stub_gen::derive::gen_stub_pymethods]
1154impl OrderType {
1155 #[new]
1157 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1158 let t = Self::type_object(py);
1159 Self::py_from_str(&t, value)
1160 }
1161
1162 const fn __hash__(&self) -> isize {
1163 *self as isize
1164 }
1165
1166 fn __str__(&self) -> String {
1167 self.to_string()
1168 }
1169
1170 #[getter]
1171 #[must_use]
1172 pub fn name(&self) -> String {
1173 self.to_string()
1174 }
1175
1176 #[getter]
1177 #[must_use]
1178 pub fn value(&self) -> u8 {
1179 *self as u8
1180 }
1181
1182 #[classmethod]
1183 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1184 EnumIterator::new::<Self>(py)
1185 }
1186
1187 #[classmethod]
1188 #[pyo3(name = "from_str")]
1189 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1190 let data_str: &str = data.extract()?;
1191 let tokenized = data_str.to_uppercase();
1192 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1193 }
1194}
1195
1196#[pyo3_stub_gen::derive::gen_stub_pymethods]
1198#[pymethods]
1199impl PositionSide {
1200 #[new]
1205 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
1206 let t = Self::type_object(py);
1207 Self::py_from_str(&t, value)
1208 }
1209
1210 #[classattr]
1214 #[pyo3(name = "NO_POSITION_SIDE")]
1215 #[allow(clippy::use_self)]
1216 const fn py_no_position_side() -> Option<PositionSide> {
1217 None
1218 }
1219
1220 const fn __hash__(&self) -> isize {
1221 *self as isize
1222 }
1223
1224 fn __str__(&self) -> String {
1225 self.to_string()
1226 }
1227
1228 #[getter]
1229 #[must_use]
1230 pub fn name(&self) -> String {
1231 self.to_string()
1232 }
1233
1234 #[getter]
1235 #[must_use]
1236 pub fn value(&self) -> u8 {
1237 *self as u8
1238 }
1239
1240 #[classmethod]
1241 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1242 EnumIterator::new::<Self>(py)
1243 }
1244
1245 #[classmethod]
1246 #[pyo3(name = "from_str")]
1247 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
1248 let data_str: &str = data.extract()?;
1249 let tokenized = data_str.to_uppercase();
1250 if tokenized == "NO_POSITION_SIDE" {
1251 Ok(None)
1252 } else {
1253 Self::from_str(&tokenized).map(Some).map_err(to_pyvalue_err)
1254 }
1255 }
1256}
1257
1258#[pymethods]
1259#[pyo3_stub_gen::derive::gen_stub_pymethods]
1260impl PriceType {
1261 #[new]
1263 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1264 let t = Self::type_object(py);
1265 Self::py_from_str(&t, value)
1266 }
1267
1268 const fn __hash__(&self) -> isize {
1269 *self as isize
1270 }
1271
1272 fn __str__(&self) -> String {
1273 self.to_string()
1274 }
1275
1276 #[getter]
1277 #[must_use]
1278 pub fn name(&self) -> String {
1279 self.to_string()
1280 }
1281
1282 #[getter]
1283 #[must_use]
1284 pub fn value(&self) -> u8 {
1285 *self as u8
1286 }
1287
1288 #[classmethod]
1289 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1290 EnumIterator::new::<Self>(py)
1291 }
1292
1293 #[classmethod]
1294 #[pyo3(name = "from_str")]
1295 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1296 let data_str: &str = data.extract()?;
1297 let tokenized = data_str.to_uppercase();
1298 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1299 }
1300
1301 #[classmethod]
1302 #[pyo3(name = "from_int")]
1303 fn py_from_int(_: &Bound<'_, PyType>, value: i32) -> PyResult<Self> {
1304 Self::from_repr(value as usize)
1305 .ok_or_else(|| to_pyvalue_err(format!("Invalid PriceType value: {value}")))
1306 }
1307}
1308
1309#[pymethods]
1310#[pyo3_stub_gen::derive::gen_stub_pymethods]
1311impl RecordFlag {
1312 #[new]
1314 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1315 let t = Self::type_object(py);
1316 Self::py_from_str(&t, value)
1317 }
1318
1319 const fn __hash__(&self) -> isize {
1320 *self as isize
1321 }
1322
1323 fn __str__(&self) -> String {
1324 self.to_string()
1325 }
1326
1327 #[getter]
1328 #[must_use]
1329 pub fn name(&self) -> String {
1330 self.to_string()
1331 }
1332
1333 #[getter]
1334 #[must_use]
1335 pub fn value(&self) -> u8 {
1336 *self as u8
1337 }
1338
1339 #[classmethod]
1340 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1341 EnumIterator::new::<Self>(py)
1342 }
1343
1344 #[classmethod]
1345 #[pyo3(name = "from_str")]
1346 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1347 let data_str: &str = data.extract()?;
1348 let tokenized = data_str.to_uppercase();
1349 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1350 }
1351
1352 #[pyo3(name = "matches")]
1354 fn py_matches(&self, value: u8) -> bool {
1355 self.matches(value)
1356 }
1357}
1358
1359#[pymethods]
1360#[pyo3_stub_gen::derive::gen_stub_pymethods]
1361impl TimeInForce {
1362 #[new]
1364 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1365 let t = Self::type_object(py);
1366 Self::py_from_str(&t, value)
1367 }
1368
1369 const fn __hash__(&self) -> isize {
1370 *self as isize
1371 }
1372
1373 fn __str__(&self) -> String {
1374 self.to_string()
1375 }
1376
1377 #[getter]
1378 #[must_use]
1379 pub fn name(&self) -> String {
1380 self.to_string()
1381 }
1382
1383 #[getter]
1384 #[must_use]
1385 pub fn value(&self) -> u8 {
1386 *self as u8
1387 }
1388
1389 #[classmethod]
1390 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1391 EnumIterator::new::<Self>(py)
1392 }
1393
1394 #[classmethod]
1395 #[pyo3(name = "from_str")]
1396 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1397 let data_str: &str = data.extract()?;
1398 let tokenized = data_str.to_uppercase();
1399 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1400 }
1401}
1402
1403#[pyo3_stub_gen::derive::gen_stub_pymethods]
1405#[pymethods]
1406impl TrailingOffsetType {
1407 #[new]
1412 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
1413 let t = Self::type_object(py);
1414 Self::py_from_str(&t, value)
1415 }
1416
1417 #[classattr]
1421 #[pyo3(name = "NO_TRAILING_OFFSET")]
1422 #[allow(clippy::use_self)]
1423 const fn py_no_trailing_offset() -> Option<TrailingOffsetType> {
1424 None
1425 }
1426
1427 const fn __hash__(&self) -> isize {
1428 *self as isize
1429 }
1430
1431 fn __str__(&self) -> String {
1432 self.to_string()
1433 }
1434
1435 #[getter]
1436 #[must_use]
1437 pub fn name(&self) -> String {
1438 self.to_string()
1439 }
1440
1441 #[getter]
1442 #[must_use]
1443 pub fn value(&self) -> u8 {
1444 *self as u8
1445 }
1446
1447 #[classmethod]
1448 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1449 EnumIterator::new::<Self>(py)
1450 }
1451
1452 #[classmethod]
1453 #[pyo3(name = "from_str")]
1454 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
1455 let data_str: &str = data.extract()?;
1456 let tokenized = data_str.to_uppercase();
1457 if tokenized == "NO_TRAILING_OFFSET" {
1458 Ok(None)
1459 } else {
1460 Self::from_str(&tokenized).map(Some).map_err(to_pyvalue_err)
1461 }
1462 }
1463}
1464
1465#[pyo3_stub_gen::derive::gen_stub_pymethods]
1467#[pymethods]
1468impl TriggerType {
1469 #[new]
1474 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
1475 let t = Self::type_object(py);
1476 Self::py_from_str(&t, value)
1477 }
1478
1479 #[classattr]
1483 #[pyo3(name = "NO_TRIGGER")]
1484 #[allow(clippy::use_self)]
1485 const fn py_no_trigger() -> Option<TriggerType> {
1486 None
1487 }
1488
1489 const fn __hash__(&self) -> isize {
1490 *self as isize
1491 }
1492
1493 fn __str__(&self) -> String {
1494 self.to_string()
1495 }
1496
1497 #[getter]
1498 #[must_use]
1499 pub fn name(&self) -> String {
1500 self.to_string()
1501 }
1502
1503 #[getter]
1504 #[must_use]
1505 pub fn value(&self) -> u8 {
1506 *self as u8
1507 }
1508
1509 #[classmethod]
1510 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1511 EnumIterator::new::<Self>(py)
1512 }
1513
1514 #[classmethod]
1515 #[pyo3(name = "from_str")]
1516 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Option<Self>> {
1517 let data_str: &str = data.extract()?;
1518 let tokenized = data_str.to_uppercase();
1519 if tokenized == "NO_TRIGGER" {
1520 Ok(None)
1521 } else {
1522 Self::from_str(&tokenized).map(Some).map_err(to_pyvalue_err)
1523 }
1524 }
1525}
1526
1527#[pymethods]
1528#[pyo3_stub_gen::derive::gen_stub_pymethods]
1529impl BookType {
1530 #[new]
1532 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1533 let t = Self::type_object(py);
1534 Self::py_from_str(&t, value)
1535 }
1536
1537 const fn __hash__(&self) -> isize {
1538 *self as isize
1539 }
1540
1541 fn __str__(&self) -> String {
1542 self.to_string()
1543 }
1544
1545 #[getter]
1546 #[must_use]
1547 pub fn name(&self) -> String {
1548 self.to_string()
1549 }
1550
1551 #[getter]
1552 #[must_use]
1553 pub fn value(&self) -> u8 {
1554 *self as u8
1555 }
1556
1557 #[classmethod]
1558 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1559 EnumIterator::new::<Self>(py)
1560 }
1561
1562 #[classmethod]
1563 #[pyo3(name = "from_str")]
1564 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1565 let data_str: &str = data.extract()?;
1566 let tokenized = data_str.to_uppercase();
1567 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1568 }
1569}
1570
1571#[pymethods]
1572#[pyo3_stub_gen::derive::gen_stub_pymethods]
1573impl TradingState {
1574 #[new]
1576 fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1577 let t = Self::type_object(py);
1578 Self::py_from_str(&t, value)
1579 }
1580
1581 const fn __hash__(&self) -> isize {
1582 *self as isize
1583 }
1584
1585 fn __str__(&self) -> String {
1586 self.to_string()
1587 }
1588
1589 #[getter]
1590 #[must_use]
1591 pub fn name(&self) -> String {
1592 self.to_string()
1593 }
1594
1595 #[getter]
1596 #[must_use]
1597 pub fn value(&self) -> u8 {
1598 *self as u8
1599 }
1600
1601 #[classmethod]
1602 fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1603 EnumIterator::new::<Self>(py)
1604 }
1605
1606 #[classmethod]
1607 #[pyo3(name = "from_str")]
1608 fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1609 let data_str: &str = data.extract()?;
1610 let tokenized = data_str.to_uppercase();
1611 Self::from_str(&tokenized).map_err(to_pyvalue_err)
1612 }
1613}