Skip to content

Commit

Permalink
Add from_str pyo3 method in identifier_for_python macro (#1599)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipmacek authored Apr 20, 2024
1 parent 8769dae commit 30aff27
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nautilus_core/model/src/python/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ macro_rules! identifier_for_python {
fn py_value(&self) -> String {
self.to_string()
}

#[staticmethod]
#[pyo3(name = "from_str")]
fn py_from_str(value: &str) -> PyResult<Self> {
Self::from_str(value).map_err(to_pyvalue_err)
}
}
};
}
26 changes: 26 additions & 0 deletions nautilus_trader/core/nautilus_pyo3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -816,23 +816,33 @@ class LogColor(Enum):

class AccountId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> AccountId: ...
def value(self) -> str: ...

class ClientId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> ClientId: ...
def value(self) -> str: ...

class ClientOrderId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> ClientOrderId: ...
@property
def value(self) -> str: ...

class ComponentId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> ComponentId: ...
def value(self) -> str: ...

class ExecAlgorithmId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> ExecAlgorithmId: ...
def value(self) -> str: ...

class InstrumentId:
Expand All @@ -847,35 +857,51 @@ class InstrumentId:

class OrderListId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> OrderListId: ...
def value(self) -> str: ...

class PositionId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> PositionId: ...
def value(self) -> str: ...

class StrategyId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> StrategyId: ...
def value(self) -> str: ...

class Symbol:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> Symbol: ...
@property
def value(self) -> str: ...

class TradeId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> TradeId: ...
def value(self) -> str: ...

class TraderId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> TraderId: ...
def value(self) -> str: ...

class Venue:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> Venue: ...
def value(self) -> str: ...

class VenueOrderId:
def __init__(self, value: str) -> None: ...
@classmethod
def from_str(cls, value: str) -> VenueOrderId: ...
def value(self) -> str: ...

### Orders
Expand Down

0 comments on commit 30aff27

Please sign in to comment.