Fix PriceResult slots serialization that broke open-group response.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-24 17:09:38 +08:00
parent 51b8bb8f8a
commit 8ea05e7064
3 changed files with 16 additions and 5 deletions
+2 -2
View File
@@ -213,8 +213,8 @@ class Matcher:
detail="opened", detail="opened",
data={ data={
"group_id": group_id, "group_id": group_id,
"perp": pf.__dict__, "perp": pf.to_dict(),
"option": of.__dict__, "option": of.to_dict(),
"initial_premium": initial_premium, "initial_premium": initial_premium,
"fees": pf.fee + of.fee, "fees": pf.fee + of.fee,
}, },
+4 -1
View File
@@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from dataclasses import dataclass from dataclasses import asdict, dataclass
@dataclass(slots=True) @dataclass(slots=True)
@@ -13,6 +13,9 @@ class PriceResult:
slip: float slip: float
notional: float notional: float
def to_dict(self) -> dict[str, float]:
return asdict(self)
def perp_fill( def perp_fill(
*, *,
+10 -2
View File
@@ -82,7 +82,15 @@ class StrategyEngine:
r = self.matcher.close_group(reason="emergency") r = self.matcher.close_group(reason="emergency")
if r.ok: if r.ok:
self._after_close() self._after_close()
return {"close": r.__dict__, "state": self.state()} return {
"close": {
"ok": r.ok,
"detail": r.detail,
"liquidity_wait": r.liquidity_wait,
"data": r.data,
},
"state": self.state(),
}
def _after_close(self) -> None: def _after_close(self) -> None:
s = get_settings() s = get_settings()
@@ -147,7 +155,7 @@ class StrategyEngine:
# 有仓:盯平仓 # 有仓:盯平仓
if pos.get("status") == "open": if pos.get("status") == "open":
self._set_state(phase="open") self._set_state(phase="open", last_error=None)
upl = self.matcher.unrealized() upl = self.matcher.unrealized()
decision = check_exits( decision = check_exits(
perp_upl=float(upl["perp_upl"]), perp_upl=float(upl["perp_upl"]),