nautilus_model/python/
enums.rs

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