Hub monitor: read-only OKX options positions aggregation (Phase B).
Expose /api/hub/options/snapshot from OKX instance and render options summary on hub monitor cards when the options capability is enabled. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1627,7 +1627,7 @@ def api_settings_meta():
|
||||
return {
|
||||
"env_disabled_ids": sorted(env_force_disabled_ids()),
|
||||
"hub_bridge_token_set": bool(HUB_BRIDGE_TOKEN),
|
||||
"capability_options": ["key", "trend"],
|
||||
"capability_options": ["key", "trend", "options"],
|
||||
"public_origin": f"{po[0]}://{po[1]}" if po else None,
|
||||
"public_origin_hint": (
|
||||
"未设置 HUB_PUBLIC_ORIGIN 时,复盘链接若为 127.0.0.1,仅服务器本机浏览器可打开"
|
||||
@@ -2306,6 +2306,9 @@ async def _fetch_exchange_flask_bundle(
|
||||
snap = results[2] if has_flask and len(results) > 2 else None
|
||||
account = results[3] if has_flask and len(results) > 3 else None
|
||||
trades_today = results[4] if has_flask and day and len(results) > 4 else None
|
||||
options_snap = None
|
||||
if has_flask and "options" in caps:
|
||||
options_snap = await _fetch_flask_json(client, ex, "/api/hub/options/snapshot")
|
||||
key_prices = None
|
||||
want_prices = HUB_BOARD_KEY_PRICES and "key" in caps
|
||||
if want_prices and isinstance(snap, dict):
|
||||
@@ -2317,6 +2320,7 @@ async def _fetch_exchange_flask_bundle(
|
||||
snap if isinstance(snap, dict) else None,
|
||||
account if isinstance(account, dict) else None,
|
||||
trades_today if isinstance(trades_today, dict) else None,
|
||||
options_snap if isinstance(options_snap, dict) else None,
|
||||
)
|
||||
|
||||
|
||||
@@ -2342,7 +2346,7 @@ def _day_stats_from_trades_body(body: dict | None) -> dict:
|
||||
async def _assemble_board_row(
|
||||
client: httpx.AsyncClient, ex: dict, agent_row: dict, *, trading_day: str
|
||||
) -> dict:
|
||||
hub_mon, meta, key_prices, snap, account, trades_today = await _fetch_exchange_flask_bundle(
|
||||
hub_mon, meta, key_prices, snap, account, trades_today, options_snap = await _fetch_exchange_flask_bundle(
|
||||
client, ex, trading_day=trading_day
|
||||
)
|
||||
if isinstance(hub_mon, dict):
|
||||
@@ -2372,6 +2376,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,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user