Fix hub full-close double-booking trend plans.

Sync active plans after hub position close, merge final close snapshots per plan, and backfill missing trade records when ending an already-stopped plan.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-08 09:06:36 +08:00
parent e71bfe095c
commit cfa28e7f4e
6 changed files with 344 additions and 7 deletions
+11
View File
@@ -1586,6 +1586,17 @@ async def api_close_position(exchange_id: str, body: ClosePositionBody):
"payload": payload,
"ok": bool(isinstance(payload, dict) and payload.get("ok")),
}
if out.get("ok") and "trend" in (ex.get("capabilities") or []):
async with httpx.AsyncClient() as flask_client:
sync_parsed = await _fetch_flask_json(
flask_client,
ex,
"/api/hub/trend/sync-flat",
method="POST",
json_body={"symbol": sym, "side": side},
)
if isinstance(sync_parsed, dict):
out["trend_sync"] = sync_parsed
_schedule_board_refresh()
return out