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::{prelude::*, types::PyType, PyTypeInfo};
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    #[classattr]
1758    #[pyo3(name = "BID")]
1759    fn py_bid() -> Self {
1760        Self::Bid
1761    }
1762
1763    #[classattr]
1764    #[pyo3(name = "ASK")]
1765    fn py_ask() -> Self {
1766        Self::Ask
1767    }
1768
1769    #[classattr]
1770    #[pyo3(name = "MID")]
1771    fn py_mid() -> Self {
1772        Self::Mid
1773    }
1774
1775    #[classattr]
1776    #[pyo3(name = "LAST")]
1777    fn py_last() -> Self {
1778        Self::Last
1779    }
1780}
1781
1782#[pymethods]
1783impl RecordFlag {
1784    #[new]
1785    fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1786        let t = Self::type_object(py);
1787        Self::py_from_str(&t, value)
1788    }
1789
1790    fn __hash__(&self) -> isize {
1791        *self as isize
1792    }
1793
1794    fn __repr__(&self) -> String {
1795        format!(
1796            "<{}.{}: '{}'>",
1797            stringify!(RecordFlag),
1798            self.name(),
1799            self.value(),
1800        )
1801    }
1802
1803    fn __str__(&self) -> String {
1804        self.to_string()
1805    }
1806
1807    #[getter]
1808    #[must_use]
1809    pub fn name(&self) -> String {
1810        self.to_string()
1811    }
1812
1813    #[getter]
1814    #[must_use]
1815    pub fn value(&self) -> u8 {
1816        *self as u8
1817    }
1818
1819    #[classmethod]
1820    fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1821        EnumIterator::new::<Self>(py)
1822    }
1823
1824    #[classmethod]
1825    #[pyo3(name = "from_str")]
1826    fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1827        let data_str: &str = data.extract()?;
1828        let tokenized = data_str.to_uppercase();
1829        Self::from_str(&tokenized).map_err(to_pyvalue_err)
1830    }
1831
1832    #[classattr]
1833    #[pyo3(name = "LAST")]
1834    fn py_last() -> Self {
1835        Self::F_LAST
1836    }
1837
1838    #[classattr]
1839    #[pyo3(name = "TOB")]
1840    fn py_tob() -> Self {
1841        Self::F_TOB
1842    }
1843
1844    #[classattr]
1845    #[pyo3(name = "SNAPSHOT")]
1846    fn py_snapshot() -> Self {
1847        Self::F_SNAPSHOT
1848    }
1849
1850    #[classattr]
1851    #[pyo3(name = "MBP")]
1852    fn py_mbp() -> Self {
1853        Self::F_MBP
1854    }
1855
1856    #[pyo3(name = "matches")]
1857    fn py_matches(&self, value: u8) -> bool {
1858        self.matches(value)
1859    }
1860}
1861
1862#[pymethods]
1863impl TimeInForce {
1864    #[new]
1865    fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1866        let t = Self::type_object(py);
1867        Self::py_from_str(&t, value)
1868    }
1869
1870    fn __hash__(&self) -> isize {
1871        *self as isize
1872    }
1873
1874    fn __repr__(&self) -> String {
1875        format!(
1876            "<{}.{}: '{}'>",
1877            stringify!(TimeInForce),
1878            self.name(),
1879            self.value(),
1880        )
1881    }
1882
1883    fn __str__(&self) -> String {
1884        self.to_string()
1885    }
1886
1887    #[getter]
1888    #[must_use]
1889    pub fn name(&self) -> String {
1890        self.to_string()
1891    }
1892
1893    #[getter]
1894    #[must_use]
1895    pub fn value(&self) -> u8 {
1896        *self as u8
1897    }
1898
1899    #[classmethod]
1900    fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1901        EnumIterator::new::<Self>(py)
1902    }
1903
1904    #[classmethod]
1905    #[pyo3(name = "from_str")]
1906    fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
1907        let data_str: &str = data.extract()?;
1908        let tokenized = data_str.to_uppercase();
1909        Self::from_str(&tokenized).map_err(to_pyvalue_err)
1910    }
1911
1912    #[classattr]
1913    #[pyo3(name = "GTC")]
1914    fn py_gtc() -> Self {
1915        Self::Gtc
1916    }
1917
1918    #[classattr]
1919    #[pyo3(name = "IOC")]
1920    fn py_ioc() -> Self {
1921        Self::Ioc
1922    }
1923
1924    #[classattr]
1925    #[pyo3(name = "FOK")]
1926    fn py_fok() -> Self {
1927        Self::Fok
1928    }
1929
1930    #[classattr]
1931    #[pyo3(name = "GTD")]
1932    fn py_gtd() -> Self {
1933        Self::Gtd
1934    }
1935
1936    #[classattr]
1937    #[pyo3(name = "DAY")]
1938    fn py_day() -> Self {
1939        Self::Day
1940    }
1941
1942    #[classattr]
1943    #[pyo3(name = "AT_THE_OPEN")]
1944    fn py_at_the_open() -> Self {
1945        Self::AtTheOpen
1946    }
1947
1948    #[classattr]
1949    #[pyo3(name = "AT_THE_CLOSE")]
1950    fn py_at_the_close() -> Self {
1951        Self::AtTheClose
1952    }
1953}
1954
1955#[pymethods]
1956impl TrailingOffsetType {
1957    #[new]
1958    fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
1959        let t = Self::type_object(py);
1960        Self::py_from_str(&t, value)
1961    }
1962
1963    fn __hash__(&self) -> isize {
1964        *self as isize
1965    }
1966
1967    fn __repr__(&self) -> String {
1968        format!(
1969            "<{}.{}: '{}'>",
1970            stringify!(TrailingOffsetType),
1971            self.name(),
1972            self.value(),
1973        )
1974    }
1975
1976    fn __str__(&self) -> String {
1977        self.to_string()
1978    }
1979
1980    #[getter]
1981    #[must_use]
1982    pub fn name(&self) -> String {
1983        self.to_string()
1984    }
1985
1986    #[getter]
1987    #[must_use]
1988    pub fn value(&self) -> u8 {
1989        *self as u8
1990    }
1991
1992    #[classmethod]
1993    fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
1994        EnumIterator::new::<Self>(py)
1995    }
1996
1997    #[classmethod]
1998    #[pyo3(name = "from_str")]
1999    fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
2000        let data_str: &str = data.extract()?;
2001        let tokenized = data_str.to_uppercase();
2002        Self::from_str(&tokenized).map_err(to_pyvalue_err)
2003    }
2004
2005    #[classattr]
2006    #[pyo3(name = "NO_TRAILING_OFFSET")]
2007    fn py_no_trailing_offset() -> Self {
2008        Self::NoTrailingOffset
2009    }
2010
2011    #[classattr]
2012    #[pyo3(name = "PRICE")]
2013    fn py_price() -> Self {
2014        Self::Price
2015    }
2016
2017    #[classattr]
2018    #[pyo3(name = "BASIS_POINTS")]
2019    fn py_basis_points() -> Self {
2020        Self::BasisPoints
2021    }
2022
2023    #[classattr]
2024    #[pyo3(name = "TICKS")]
2025    fn py_ticks() -> Self {
2026        Self::Ticks
2027    }
2028
2029    #[classattr]
2030    #[pyo3(name = "PRICE_TIER")]
2031    fn py_price_tier() -> Self {
2032        Self::PriceTier
2033    }
2034}
2035
2036#[pymethods]
2037impl TriggerType {
2038    #[new]
2039    fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
2040        let t = Self::type_object(py);
2041        Self::py_from_str(&t, value)
2042    }
2043
2044    fn __hash__(&self) -> isize {
2045        *self as isize
2046    }
2047
2048    fn __repr__(&self) -> String {
2049        format!(
2050            "<{}.{}: '{}'>",
2051            stringify!(TriggerType),
2052            self.name(),
2053            self.value(),
2054        )
2055    }
2056
2057    fn __str__(&self) -> String {
2058        self.to_string()
2059    }
2060
2061    #[getter]
2062    #[must_use]
2063    pub fn name(&self) -> String {
2064        self.to_string()
2065    }
2066
2067    #[getter]
2068    #[must_use]
2069    pub fn value(&self) -> u8 {
2070        *self as u8
2071    }
2072
2073    #[classmethod]
2074    fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
2075        EnumIterator::new::<Self>(py)
2076    }
2077
2078    #[classmethod]
2079    #[pyo3(name = "from_str")]
2080    fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
2081        let data_str: &str = data.extract()?;
2082        let tokenized = data_str.to_uppercase();
2083        Self::from_str(&tokenized).map_err(to_pyvalue_err)
2084    }
2085
2086    #[classattr]
2087    #[pyo3(name = "NO_TRIGGER")]
2088    fn py_no_trigger() -> Self {
2089        Self::NoTrigger
2090    }
2091
2092    #[classattr]
2093    #[pyo3(name = "DEFAULT")]
2094    fn py_default() -> Self {
2095        Self::Default
2096    }
2097
2098    #[classattr]
2099    #[pyo3(name = "BID_ASK")]
2100    fn py_bid_ask() -> Self {
2101        Self::BidAsk
2102    }
2103
2104    #[classattr]
2105    #[pyo3(name = "LAST_PRICE")]
2106    fn py_last_trade() -> Self {
2107        Self::LastPrice
2108    }
2109
2110    #[classattr]
2111    #[pyo3(name = "DOUBLE_LAST")]
2112    fn py_double_last() -> Self {
2113        Self::DoubleLast
2114    }
2115
2116    #[classattr]
2117    #[pyo3(name = "DOUBLE_BID_ASK")]
2118    fn py_double_bid_ask() -> Self {
2119        Self::DoubleBidAsk
2120    }
2121
2122    #[classattr]
2123    #[pyo3(name = "LAST_OR_BID_ASK")]
2124    fn py_last_or_bid_ask() -> Self {
2125        Self::LastOrBidAsk
2126    }
2127
2128    #[classattr]
2129    #[pyo3(name = "MID_POINT")]
2130    fn py_mid_point() -> Self {
2131        Self::MidPoint
2132    }
2133
2134    #[classattr]
2135    #[pyo3(name = "MARK_PRICE")]
2136    fn py_mark_price() -> Self {
2137        Self::MarkPrice
2138    }
2139
2140    #[classattr]
2141    #[pyo3(name = "INDEX_PRICE")]
2142    fn py_index_price() -> Self {
2143        Self::IndexPrice
2144    }
2145}
2146
2147#[pymethods]
2148impl BookType {
2149    #[new]
2150    fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
2151        let t = Self::type_object(py);
2152        Self::py_from_str(&t, value)
2153    }
2154
2155    fn __hash__(&self) -> isize {
2156        *self as isize
2157    }
2158
2159    fn __repr__(&self) -> String {
2160        format!(
2161            "<{}.{}: '{}'>",
2162            stringify!(BookType),
2163            self.name(),
2164            self.value(),
2165        )
2166    }
2167
2168    fn __str__(&self) -> String {
2169        self.to_string()
2170    }
2171
2172    #[getter]
2173    #[must_use]
2174    pub fn name(&self) -> String {
2175        self.to_string()
2176    }
2177
2178    #[getter]
2179    #[must_use]
2180    pub fn value(&self) -> u8 {
2181        *self as u8
2182    }
2183
2184    #[classmethod]
2185    fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
2186        EnumIterator::new::<Self>(py)
2187    }
2188
2189    #[classmethod]
2190    #[pyo3(name = "from_str")]
2191    fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
2192        let data_str: &str = data.extract()?;
2193        let tokenized = data_str.to_uppercase();
2194        Self::from_str(&tokenized).map_err(to_pyvalue_err)
2195    }
2196
2197    #[classattr]
2198    #[pyo3(name = "L1_MBP")]
2199    fn py_l1_mbp() -> Self {
2200        Self::L1_MBP
2201    }
2202
2203    #[classattr]
2204    #[pyo3(name = "L2_MBP")]
2205    fn py_l2_mbp() -> Self {
2206        Self::L2_MBP
2207    }
2208
2209    #[classattr]
2210    #[pyo3(name = "L3_MBO")]
2211    fn py_l3_mbo() -> Self {
2212        Self::L3_MBO
2213    }
2214}
2215
2216#[pymethods]
2217impl TradingState {
2218    #[new]
2219    fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
2220        let t = Self::type_object(py);
2221        Self::py_from_str(&t, value)
2222    }
2223
2224    fn __hash__(&self) -> isize {
2225        *self as isize
2226    }
2227
2228    fn __repr__(&self) -> String {
2229        format!(
2230            "<{}.{}: '{}'>",
2231            stringify!(TradingState),
2232            self.name(),
2233            self.value(),
2234        )
2235    }
2236
2237    fn __str__(&self) -> String {
2238        self.to_string()
2239    }
2240
2241    #[getter]
2242    #[must_use]
2243    pub fn name(&self) -> String {
2244        self.to_string()
2245    }
2246
2247    #[getter]
2248    #[must_use]
2249    pub fn value(&self) -> u8 {
2250        *self as u8
2251    }
2252
2253    #[classmethod]
2254    fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
2255        EnumIterator::new::<Self>(py)
2256    }
2257
2258    #[classmethod]
2259    #[pyo3(name = "from_str")]
2260    fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
2261        let data_str: &str = data.extract()?;
2262        let tokenized = data_str.to_uppercase();
2263        Self::from_str(&tokenized).map_err(to_pyvalue_err)
2264    }
2265
2266    #[classattr]
2267    #[pyo3(name = "ACTIVE")]
2268    fn py_active() -> Self {
2269        Self::Active
2270    }
2271
2272    #[classattr]
2273    #[pyo3(name = "HALTED")]
2274    fn py_halted() -> Self {
2275        Self::Halted
2276    }
2277
2278    #[classattr]
2279    #[pyo3(name = "REDUCING")]
2280    fn py_reducing() -> Self {
2281        Self::Reducing
2282    }
2283}