feat(options): push chain asks/bids via OKX WS + SSE

Replace soft REST polling with OKX public tickers WS ingest and browser SSE patches so list quotes stay live while watching an expiry.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-11 11:49:49 +08:00
parent 24bb8532c4
commit 14a7adae1f
7 changed files with 959 additions and 7 deletions
+17
View File
@@ -61,6 +61,14 @@ def install_options_trading(app: Flask, repo_root: str, app_module: Any) -> None
register_options_routes(app, cfg)
_register_options_hub_bridge(app, cfg)
if enabled:
try:
from lib.options.options_quote_live_lib import register_options_quote_live_routes
register_options_quote_live_routes(app, cfg["login_required"])
except Exception as e:
import logging
logging.getLogger(__name__).exception("options quote live init failed: %s", e)
_start_monitor_thread(app, cfg)
@@ -381,6 +389,14 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
# 热更新:每次读 env,保存配置后刷新链即可生效
ask_liq_filter = _env_bool("OKX_OPTIONS_CHAIN_ASK_LIQ_FILTER_ENABLED", True)
budget_buffer = _env_float("OKX_OPTIONS_BUDGET_BUFFER", 0.95)
if expiries:
try:
from lib.options.options_quote_live_lib import options_quote_live
watch_exp = (request.args.get("exp_time") or "").strip() or None
options_quote_live.seed_from_chain(chain, exp_time=watch_exp)
except Exception:
pass
if not expiries:
return jsonify(
{
@@ -401,6 +417,7 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
"ask_liq_filter_enabled": ask_liq_filter,
"budget_buffer": budget_buffer,
"trade_budget": cfg["trade_budget"],
"quote_live": True,
}
)