Refresh perp mark from public ticker when position metrics are unavailable.
Sim/no-keys mode was falling back to entry so 标记 stayed frozen at open price. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from typing import Any, Optional
|
||||
|
||||
from lib.hedge_plan.hedge_plan_book_lib import fetch_perp_close_vwap
|
||||
from lib.hedge_plan.hedge_plan_book_lib import fetch_perp_close_vwap, fetch_perp_mark_px
|
||||
from lib.hedge_plan.hedge_plan_option_primary_lib import (
|
||||
estimate_combo_net_pnl,
|
||||
fee_rate,
|
||||
@@ -205,6 +205,9 @@ def build_live_hedge_cards(cfg: dict[str, Any], conn: Any) -> list[dict[str, Any
|
||||
margin = _sf(m.get("initial_margin") or m.get("margin"))
|
||||
except Exception:
|
||||
pass
|
||||
# 模拟盘/无私钥时持仓 metrics 为空,标记会卡在开仓价 → 改拉公开 ticker
|
||||
if perp_mark is None or perp_mark <= 0:
|
||||
perp_mark = fetch_perp_mark_px(ex_perp, sym)
|
||||
if perp_mark is None or perp_mark <= 0:
|
||||
perp_mark = perp_entry
|
||||
if live_contracts and live_contracts > 0:
|
||||
|
||||
Reference in New Issue
Block a user