cadc59e6dc
- xt_gateway: _open_session抽离, reconnect(stop旧trader+重建), is_alive(query探活), _retry_with_reconnect(query/order失败重连重试一次) - query_account/positions/place_order包重试: 断线(异常/None)→reconnect→重试, broker拒单(order_id<=0)不重连 - bridge /health: is_alive真实探活(5s缓存)+断线后台reconnect(不阻塞), 不再假阳性 - trade_calendar: is_trading_day(周一-周五), /order非交易日加warning(120141提示) - test_gateway15+test_trade_calendar6=NAS21passed, 回归bridge_client/d4a 10绿 - 修复Issue#4运维发现: miniQMT重启后bridge自动重连(无需手动重启)
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""D-2 交易日判断单元测试(纯函数,无外部依赖)。"""
|
|
from datetime import date
|
|
|
|
from sanguo_qmt_bridge.trade_calendar import is_trading_day
|
|
|
|
|
|
class TestIsTradingDay:
|
|
def test_weekday_is_trading_day(self):
|
|
assert is_trading_day(date(2026, 7, 13)) is True # 周一
|
|
|
|
def test_friday_is_trading_day(self):
|
|
assert is_trading_day(date(2026, 7, 17)) is True # 周五
|
|
|
|
def test_saturday_is_not_trading_day(self):
|
|
assert is_trading_day(date(2026, 7, 18)) is False # 周六
|
|
|
|
def test_sunday_is_not_trading_day(self):
|
|
assert is_trading_day(date(2026, 7, 19)) is False # 周日
|
|
|
|
def test_default_uses_today(self):
|
|
"""无参数时用今天,至少返回 bool 不崩溃。"""
|
|
result = is_trading_day()
|
|
assert isinstance(result, bool)
|
|
|
|
def test_full_week(self):
|
|
"""完整一周:周一到周五 True,周六周日 False。"""
|
|
week = [
|
|
(date(2026, 7, 13), True), # Mon
|
|
(date(2026, 7, 14), True), # Tue
|
|
(date(2026, 7, 15), True), # Wed
|
|
(date(2026, 7, 16), True), # Thu
|
|
(date(2026, 7, 17), True), # Fri
|
|
(date(2026, 7, 18), False), # Sat
|
|
(date(2026, 7, 19), False), # Sun
|
|
]
|
|
for day, expected in week:
|
|
assert is_trading_day(day) is expected, f"{day} expected {expected}"
|