fix: Gate hub close sync and trade record open stop-loss snapshot

Sync order monitors from Gate position history after hub flat close. Store and display initial_stop_loss in trade records instead of post-amend exchange stops.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-09 18:01:59 +08:00
parent 02d2a6c70b
commit 59a45ed027
11 changed files with 449 additions and 40 deletions
+22 -10
View File
@@ -1802,17 +1802,29 @@ 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 []):
if out.get("ok"):
ex_key = (ex.get("key") or "").strip().lower()
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
if ex_key in ("gate", "gate_bot"):
order_sync = await _fetch_flask_json(
flask_client,
ex,
"/api/hub/order/sync-flat",
method="POST",
json_body={"symbol": sym, "side": side},
)
if isinstance(order_sync, dict):
out["order_sync"] = order_sync
if "trend" in (ex.get("capabilities") or []):
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