update
This commit is contained in:
+11
-1
@@ -8,6 +8,7 @@ from core.logger import LogLevel, PrintLog
|
||||
from xtquant.xttrader import XtQuantTrader, XtQuantTraderCallback
|
||||
from xtquant.xttype import StockAccount
|
||||
from xtquant import xtconstant, xtdata
|
||||
import core.eventbus as eBus
|
||||
|
||||
class QmtV(XtQuantTraderCallback):
|
||||
def __init__(self) -> None:
|
||||
@@ -41,6 +42,7 @@ class QmtV(XtQuantTraderCallback):
|
||||
if subscribe_result != 0:
|
||||
self.inited = False
|
||||
return
|
||||
self.startMarketDataSubscription()
|
||||
|
||||
|
||||
def getStockPosition(self, stock_code: str):
|
||||
@@ -126,11 +128,19 @@ class QmtV(XtQuantTraderCallback):
|
||||
|
||||
|
||||
# ========================================#
|
||||
def startMarketDataSubscription(self):
|
||||
self.subscriptionId = xtdata.subscribe_whole_quote(['SH', 'SZ'], self.onDataUpdate)
|
||||
|
||||
def stopMarketDataSubscription(self):
|
||||
PrintLog(LogLevel.INFO, '- 停止市场数据订阅')
|
||||
|
||||
if self.subscriptionId is not None and self.subscriptionId > 0:
|
||||
xtdata.unsubscribe_quote(self.subscriptionId)
|
||||
|
||||
# ====== 市场回调方法 -- 以下方法由XtQuantData调用 ======
|
||||
def onDataUpdate(self, data):
|
||||
# 收集所有市场数据用于市场监控
|
||||
print(f'market data update {len(data)}')
|
||||
eBus.event_bus.publish(eBus.MarketDataUpdate, data)
|
||||
|
||||
|
||||
# ====== 市场回调方法 -- 以下方法由XtQuantTrader调用 ======
|
||||
|
||||
Reference in New Issue
Block a user