Fix dashboard position limit flicker by unifying active count across APIs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -62,6 +62,7 @@ def build_risk_overview(
|
||||
daily_position_limit,
|
||||
daily_trading_risk_pct_limit,
|
||||
daily_trading_risk_used_pct,
|
||||
effective_active_position_count,
|
||||
ensure_account_risk_schema,
|
||||
get_risk_status,
|
||||
manual_close_daily_limit,
|
||||
@@ -76,10 +77,22 @@ def build_risk_overview(
|
||||
get_max_margin_pct,
|
||||
get_roll_max_margin_pct,
|
||||
get_sizing_mode,
|
||||
get_trading_mode,
|
||||
)
|
||||
|
||||
ensure_account_risk_schema(conn)
|
||||
risk = dict(get_risk_status(conn, equity=equity) or {})
|
||||
mode = get_trading_mode(get_setting)
|
||||
ctp_connected = False
|
||||
try:
|
||||
from modules.ctp.vnpy_bridge import ctp_status
|
||||
|
||||
ctp_connected = bool(ctp_status(mode).get("connected"))
|
||||
except Exception:
|
||||
pass
|
||||
active_n = effective_active_position_count(
|
||||
conn, mode, ctp_connected=ctp_connected,
|
||||
)
|
||||
risk = dict(get_risk_status(conn, equity=equity, active_count=active_n) or {})
|
||||
row = conn.execute("SELECT * FROM account_risk_state WHERE id=1").fetchone()
|
||||
td = trading_day_label()
|
||||
stored_td = str(row["trading_day"] or "") if row else ""
|
||||
|
||||
Reference in New Issue
Block a user