Fix PriceResult slots serialization that broke open-group response.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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(
|
||||||
*,
|
*,
|
||||||
|
|||||||
@@ -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"]),
|
||||||
|
|||||||
Reference in New Issue
Block a user