模型,评分,修复网格策略市场状态监听
This commit is contained in:
+18
-2
@@ -242,6 +242,18 @@ class DummyQmtV:
|
||||
"""停止市场数据订阅"""
|
||||
PrintLog(LogLevel.INFO, '- 停止市场数据订阅 (模拟)')
|
||||
|
||||
def _is_trading_time(self) -> bool:
|
||||
import zoneinfo
|
||||
beijing_tz = zoneinfo.ZoneInfo('Asia/Shanghai')
|
||||
now = datetime.datetime.now(beijing_tz)
|
||||
if now.weekday() >= 5:
|
||||
return False
|
||||
t = now.time()
|
||||
return (
|
||||
datetime.time(9, 30) <= t <= datetime.time(11, 30) or
|
||||
datetime.time(13, 0) <= t <= datetime.time(15, 0)
|
||||
)
|
||||
|
||||
def _generate_market_data(self):
|
||||
"""生成模拟市场数据"""
|
||||
stocks = ['600519', '000858', '600036', '000001', '000002', '600000']
|
||||
@@ -263,8 +275,12 @@ class DummyQmtV:
|
||||
base_prices[i] = data['last_price']
|
||||
|
||||
self.lastMarketDataUpdateTimestamp = time.time()
|
||||
self.isMarketActive = True
|
||||
eBus.event_bus.publish(eBus.EventMarketActiveSwitch, True)
|
||||
if self._is_trading_time():
|
||||
self.isMarketActive = True
|
||||
eBus.event_bus.publish(eBus.EventMarketActiveSwitch, True)
|
||||
else:
|
||||
self.isMarketActive = False
|
||||
eBus.event_bus.publish(eBus.EventMarketActiveSwitch, False)
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user