Speed up equity/position display after CTP reconnect and auto-refresh stale sessions before market open.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-03 21:17:15 +08:00
parent 61481d5749
commit d6776d2b8e
4 changed files with 110 additions and 21 deletions
+14 -1
View File
@@ -18,7 +18,7 @@ from modules.market.market_sessions import (
is_trading_session,
should_keep_ctp_connected,
)
from modules.ctp.vnpy_bridge import ctp_start_connect, ctp_status
from modules.ctp.vnpy_bridge import ctp_start_connect, ctp_status, ctp_session_needs_reconnect
logger = logging.getLogger(__name__)
@@ -105,6 +105,19 @@ def start_ctp_premarket_connect_worker(
mode,
mins_b,
)
elif (
st.get("connected")
and not st.get("connecting")
and int(st.get("login_cooldown_sec") or 0) <= 0
and (
in_premarket_connect_window(minutes_before=mins_b)
or is_trading_session()
)
and ctp_session_needs_reconnect(mode)
):
info = ctp_start_connect(mode, force=True, scheduled=True)
if info.get("started") or info.get("connecting"):
logger.info("CTP 会话刷新(盘前/交易时段)[%s]", mode)
if is_trading_session():
sleep_sec = TRADING_CHECK_INTERVAL_SEC
elif in_premarket_connect_window(minutes_before=mins_b):