Revert "fix(options): speed up chain refresh with fast path and non-blocking UI"
This reverts commit 6fad68f7b1.
This commit is contained in:
@@ -374,24 +374,6 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
u = (request.args.get("underlying") or cfg["default_underly"]).upper()
|
||||
# 热更新:链展示天数每次读 env,保存后刷新链即可
|
||||
chain_max_dte = _env_float("OKX_OPTIONS_CHAIN_MAX_DTE_DAYS", float(cfg.get("chain_max_dte_days") or 14))
|
||||
fast = (request.args.get("fast") or "").strip().lower() in ("1", "true", "yes")
|
||||
force_tickers = (request.args.get("force_tickers") or "").strip().lower() in ("1", "true", "yes")
|
||||
watch_exp = (request.args.get("exp_time") or "").strip() or None
|
||||
live_index = None
|
||||
live_tickers = None
|
||||
ws_fresh = False
|
||||
try:
|
||||
from lib.options.options_quote_live_lib import options_quote_live
|
||||
|
||||
ws_fresh = options_quote_live.is_ws_fresh()
|
||||
live_index = options_quote_live.index_px_for(u)
|
||||
live_tickers = options_quote_live.as_okx_tickers(u) or None
|
||||
except Exception:
|
||||
pass
|
||||
# fast: WS 已热则跳过整家族 REST tickers(最慢的一步),用 WS 缓存覆盖
|
||||
fetch_tickers = True
|
||||
if fast and ws_fresh and not force_tickers:
|
||||
fetch_tickers = False
|
||||
try:
|
||||
chain = cfg["build_option_chain"](
|
||||
ex,
|
||||
@@ -399,10 +381,6 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
max_dte_days=chain_max_dte,
|
||||
itm_only=False,
|
||||
itm_max_dist_usd=cfg["itm_max_dist"],
|
||||
index_px=live_index,
|
||||
tickers_override=live_tickers,
|
||||
fetch_tickers=fetch_tickers,
|
||||
force_tickers=force_tickers,
|
||||
)
|
||||
except Exception as e:
|
||||
return jsonify({"ok": False, "msg": f"加载期权链失败: {e}"})
|
||||
@@ -415,7 +393,8 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
try:
|
||||
from lib.options.options_quote_live_lib import options_quote_live
|
||||
|
||||
options_quote_live.schedule_seed_from_chain(chain, exp_time=watch_exp)
|
||||
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:
|
||||
@@ -428,8 +407,6 @@ 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"],
|
||||
"chain_fast": fast,
|
||||
"ws_fresh": ws_fresh,
|
||||
}
|
||||
)
|
||||
return jsonify(
|
||||
@@ -441,9 +418,6 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
|
||||
"budget_buffer": budget_buffer,
|
||||
"trade_budget": cfg["trade_budget"],
|
||||
"quote_live": True,
|
||||
"chain_fast": fast,
|
||||
"ws_fresh": ws_fresh,
|
||||
"tickers_fetched": fetch_tickers,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user