fix实盘统计超时:先拉交易所/指数再短事务写冻结,避免握库锁拖死中控。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-08 23:35:39 +08:00
parent bb9d14dd73
commit 3f621835a9
3 changed files with 222 additions and 90 deletions
+5 -2
View File
@@ -1285,8 +1285,11 @@ def register_options_routes(app: Flask, cfg: dict[str, Any]) -> None:
raw_live = cfg["fetch_option_positions"](ex)
if raw_live is None:
return jsonify({"ok": False, "msg": "获取期权持仓失败"})
# 实盘:期权历史交易所原生盈亏;模拟盘:本地结算
stats = compute_options_stats_auto(cfg, ex)
try:
# 实盘:期权历史交易所原生盈亏;模拟盘:本地结算
stats = compute_options_stats_auto(cfg, ex)
except Exception as e:
return jsonify({"ok": False, "msg": f"统计失败: {e}"})
open_float = sum_options_net_pnl_usdc(cfg, ex, raw_live)
net_realized = _safe_float(stats.get("net_realized_pnl")) or 0.0
total_pnl = None