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, CurrencyType, 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)
}
}
#[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 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 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)
}
}