This commit is contained in:
2026-09-03 11:33:43 +08:00
parent d5303cc22b
commit e6a5096353
38 changed files with 1911 additions and 2742 deletions

View File

@@ -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: