Lighten hub options snapshot by skipping history stats.
Monitor board only needs positions, balances, and targets; drop the OKX positions-history pull each poll, and surface timeout errors via msg. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2462,6 +2462,17 @@ def _day_stats_from_trades_body(body: dict | None) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def _normalize_options_snap(options_snap: dict | None) -> dict | None:
|
||||
"""超时等失败常只有 error 无 msg;前端只认 msg,补齐以免落成「期权数据不可用」."""
|
||||
if not isinstance(options_snap, dict):
|
||||
return options_snap
|
||||
if options_snap.get("ok") is False and not (options_snap.get("msg") or "").strip():
|
||||
err = options_snap.get("error")
|
||||
if err is not None and str(err).strip():
|
||||
return {**options_snap, "msg": str(err).strip()}
|
||||
return options_snap
|
||||
|
||||
|
||||
async def _assemble_board_row(
|
||||
client: httpx.AsyncClient, ex: dict, agent_row: dict, *, trading_day: str
|
||||
) -> dict:
|
||||
@@ -2495,7 +2506,7 @@ async def _assemble_board_row(
|
||||
"account_ok": acct_ok,
|
||||
"day_stats": _day_stats_from_trades_body(trades_today),
|
||||
"force_close": snap.get("force_close") if isinstance(snap, dict) else None,
|
||||
"options": options_snap,
|
||||
"options": _normalize_options_snap(options_snap if isinstance(options_snap, dict) else None),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user