use std::str::FromStr;
use nautilus_core::python::to_pyvalue_err;
use pyo3::{PyTypeInfo, prelude::*, types::PyType};
use crate::{
enums::{
AccountType, AggregationSource, AggressorSide, AssetClass, BarAggregation, BarIntervalType,
BetSide, BookAction, BookType, ContingencyType, ContinuousFutureAdjustmentType,
CurrencyType, GreeksConvention, InstrumentClass, InstrumentCloseType, LiquiditySide,
MarketStatus, MarketStatusAction, OmsType, OptionKind, OrderSide, OrderStatus, OrderType,
OtoTriggerMode, PositionAdjustmentType, PositionSide, PriceType, RecordFlag, TimeInForce,
TradingState, TrailingOffsetType, TriggerType,
},
python::common::EnumIterator,
};
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl AccountType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl PositionAdjustmentType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl AggregationSource {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl AggressorSide {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl AssetClass {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl InstrumentClass {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
#[pyo3(name = "has_expiration")]
#[must_use]
pub const fn py_has_expiration(&self) -> bool {
self.has_expiration()
}
#[pyo3(name = "allows_negative_price")]
#[must_use]
pub const fn py_allows_negative_price(&self) -> bool {
self.allows_negative_price()
}
#[pyo3(name = "parent_suffix")]
#[must_use]
pub const fn py_parent_suffix(&self) -> Option<&'static str> {
self.parent_suffix()
}
#[classmethod]
#[pyo3(name = "try_from_parent_suffix")]
#[must_use]
pub fn py_try_from_parent_suffix(_: &Bound<'_, PyType>, suffix: &str) -> Option<Self> {
Self::try_from_parent_suffix(suffix)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl BarAggregation {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl BarIntervalType {
const fn __hash__(&self) -> isize {
*self as isize
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl BetSide {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
#[classmethod]
#[pyo3(name = "from_order_side")]
fn py_from_order_side(_: &Bound<'_, PyType>, order_side: OrderSide) -> Self {
order_side.into()
}
#[pyo3(name = "opposite")]
fn py_opposite(&self) -> Self {
self.opposite()
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl BookAction {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl ContingencyType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl ContinuousFutureAdjustmentType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[getter(is_ratio)]
#[must_use]
pub const fn py_is_ratio(&self) -> bool {
self.is_ratio()
}
#[getter(is_backward)]
#[must_use]
pub const fn py_is_backward(&self) -> bool {
self.is_backward()
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl CurrencyType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl InstrumentCloseType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl LiquiditySide {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl MarketStatus {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl MarketStatusAction {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl OmsType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl OptionKind {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl GreeksConvention {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl OtoTriggerMode {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl OrderSide {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl OrderStatus {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl OrderType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl PositionSide {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl PriceType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
#[classmethod]
#[pyo3(name = "from_int")]
fn py_from_int(_: &Bound<'_, PyType>, value: i32) -> PyResult<Self> {
Self::from_repr(value as usize)
.ok_or_else(|| to_pyvalue_err(format!("Invalid PriceType value: {value}")))
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl RecordFlag {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
#[pyo3(name = "matches")]
fn py_matches(&self, value: u8) -> bool {
self.matches(value)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl TimeInForce {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl TrailingOffsetType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl TriggerType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl BookType {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}
#[pymethods]
#[pyo3_stub_gen::derive::gen_stub_pymethods]
impl TradingState {
#[new]
fn py_new(py: Python<'_>, value: &Bound<'_, PyAny>) -> PyResult<Self> {
let t = Self::type_object(py);
Self::py_from_str(&t, value)
}
const fn __hash__(&self) -> isize {
*self as isize
}
fn __str__(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn name(&self) -> String {
self.to_string()
}
#[getter]
#[must_use]
pub fn value(&self) -> u8 {
*self as u8
}
#[classmethod]
fn variants(_: &Bound<'_, PyType>, py: Python<'_>) -> EnumIterator {
EnumIterator::new::<Self>(py)
}
#[classmethod]
#[pyo3(name = "from_str")]
fn py_from_str(_: &Bound<'_, PyType>, data: &Bound<'_, PyAny>) -> PyResult<Self> {
let data_str: &str = data.extract()?;
let tokenized = data_str.to_uppercase();
Self::from_str(&tokenized).map_err(to_pyvalue_err)
}
}