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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user