Add CTP auto-connect toggle to stop off-hours reconnect attempts.
When disabled, disconnect immediately and skip auto-reconnect, premarket connect, and TCP probes that fail outside SimNow trading hours. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import threading
|
||||
import time
|
||||
from typing import Callable
|
||||
|
||||
from ctp_settings import is_ctp_auto_connect_enabled
|
||||
from market_sessions import in_premarket_connect_window
|
||||
from vnpy_bridge import ctp_start_connect, ctp_status
|
||||
|
||||
@@ -39,6 +40,7 @@ def _minutes_before_open() -> int:
|
||||
def start_ctp_premarket_connect_worker(
|
||||
*,
|
||||
get_mode_fn: Callable[[], str],
|
||||
get_setting_fn: Callable[[str, str], str] | None = None,
|
||||
interval: int = CHECK_INTERVAL_SEC,
|
||||
) -> None:
|
||||
"""在交易开始前若干分钟自动发起 CTP 连接。"""
|
||||
@@ -47,8 +49,15 @@ def start_ctp_premarket_connect_worker(
|
||||
time.sleep(10)
|
||||
while True:
|
||||
try:
|
||||
if _premarket_enabled() and in_premarket_connect_window(
|
||||
minutes_before=_minutes_before_open(),
|
||||
gs = get_setting_fn
|
||||
if gs is None:
|
||||
from fee_specs import get_setting as gs
|
||||
if (
|
||||
is_ctp_auto_connect_enabled(gs)
|
||||
and _premarket_enabled()
|
||||
and in_premarket_connect_window(
|
||||
minutes_before=_minutes_before_open(),
|
||||
)
|
||||
):
|
||||
mode = get_mode_fn()
|
||||
st = ctp_status(mode)
|
||||
|
||||
Reference in New Issue
Block a user