Reconcile stale open trades; report position ticket and history closes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-21 10:15:07 +08:00
parent 997dca7a6e
commit 60ecc65f1c
4 changed files with 173 additions and 11 deletions
+24
View File
@@ -105,6 +105,30 @@ def report_trade(payload: dict[str, Any]) -> Optional[int]:
return None
def reconcile_trades(open_tickets: list, symbol: str = "") -> int:
"""告知中控当前仍持仓的单号;其余未平仓记录将被结束「持仓中」。"""
d = load_device()
if not d.get("token") or not d.get("server"):
return 0
try:
r = _request(
"POST",
d["server"],
"/api/v1/trades/reconcile",
body={
"open_tickets": [str(t) for t in (open_tickets or [])],
"symbol": symbol,
},
token=d["token"],
timeout=15,
)
if r.get("ok"):
return int(r.get("closed") or 0)
except HubError:
return 0
return 0
def report_bars(symbol: str, timeframe: str, bars: list[dict]) -> int:
d = load_device()
if not d.get("token") or not d.get("server") or not bars: