fix bug
This commit is contained in:
@@ -133,6 +133,13 @@ class Assets:
|
||||
)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class Portfolio:
|
||||
assets: Assets
|
||||
positions: dict[str, PositionItem]
|
||||
orders: list[OrderItem]
|
||||
|
||||
|
||||
def _trade_datetime(data: dict[str, Any]) -> datetime | None:
|
||||
date = str(data.get("m_strInsertDate") or "")
|
||||
clock = str(data.get("m_strInsertTime") or "").replace(":", "").zfill(6)
|
||||
@@ -148,6 +155,16 @@ class Tick:
|
||||
last_close: float = 0.0
|
||||
raw: dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: Any) -> "Tick":
|
||||
if not isinstance(data, dict):
|
||||
return cls()
|
||||
return cls(
|
||||
last_price=_number(data.get("lastPrice", data.get("last_price", data.get("LastPrice")))),
|
||||
last_close=_number(data.get("lastClose", data.get("last_close", data.get("LastClose")))),
|
||||
raw=data,
|
||||
)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class HistoryDataRequest:
|
||||
|
||||
Reference in New Issue
Block a user