[Add] HbdmGateway auto resubscribe market data when connected
This commit is contained in:
parent
a833576ebb
commit
65133141f8
@ -5,7 +5,7 @@ from vnpy.trader.ui import MainWindow, create_qapp
|
|||||||
|
|
||||||
# from vnpy.gateway.bitmex import BitmexGateway
|
# from vnpy.gateway.bitmex import BitmexGateway
|
||||||
# from vnpy.gateway.futu import FutuGateway
|
# from vnpy.gateway.futu import FutuGateway
|
||||||
from vnpy.gateway.ib import IbGateway
|
# from vnpy.gateway.ib import IbGateway
|
||||||
# from vnpy.gateway.ctp import CtpGateway
|
# from vnpy.gateway.ctp import CtpGateway
|
||||||
# # from vnpy.gateway.ctptest import CtptestGateway
|
# # from vnpy.gateway.ctptest import CtptestGateway
|
||||||
# from vnpy.gateway.femas import FemasGateway
|
# from vnpy.gateway.femas import FemasGateway
|
||||||
@ -17,7 +17,7 @@ from vnpy.gateway.ib import IbGateway
|
|||||||
# from vnpy.gateway.onetoken import OnetokenGateway
|
# from vnpy.gateway.onetoken import OnetokenGateway
|
||||||
# from vnpy.gateway.okexf import OkexfGateway
|
# from vnpy.gateway.okexf import OkexfGateway
|
||||||
# from vnpy.gateway.xtp import XtpGateway
|
# from vnpy.gateway.xtp import XtpGateway
|
||||||
# from vnpy.gateway.hbdm import HbdmGateway
|
from vnpy.gateway.hbdm import HbdmGateway
|
||||||
# from vnpy.gateway.tap import TapGateway
|
# from vnpy.gateway.tap import TapGateway
|
||||||
|
|
||||||
# from vnpy.app.cta_strategy import CtaStrategyApp
|
# from vnpy.app.cta_strategy import CtaStrategyApp
|
||||||
@ -39,7 +39,7 @@ def main():
|
|||||||
# main_engine.add_gateway(CtpGateway)
|
# main_engine.add_gateway(CtpGateway)
|
||||||
# # main_engine.add_gateway(CtptestGateway)
|
# # main_engine.add_gateway(CtptestGateway)
|
||||||
# main_engine.add_gateway(FemasGateway)
|
# main_engine.add_gateway(FemasGateway)
|
||||||
main_engine.add_gateway(IbGateway)
|
# main_engine.add_gateway(IbGateway)
|
||||||
# main_engine.add_gateway(FutuGateway)
|
# main_engine.add_gateway(FutuGateway)
|
||||||
# main_engine.add_gateway(BitmexGateway)
|
# main_engine.add_gateway(BitmexGateway)
|
||||||
# main_engine.add_gateway(TigerGateway)
|
# main_engine.add_gateway(TigerGateway)
|
||||||
@ -49,7 +49,7 @@ def main():
|
|||||||
# main_engine.add_gateway(BitfinexGateway)
|
# main_engine.add_gateway(BitfinexGateway)
|
||||||
# main_engine.add_gateway(OnetokenGateway)
|
# main_engine.add_gateway(OnetokenGateway)
|
||||||
# main_engine.add_gateway(OkexfGateway)
|
# main_engine.add_gateway(OkexfGateway)
|
||||||
# main_engine.add_gateway(HbdmGateway)
|
main_engine.add_gateway(HbdmGateway)
|
||||||
# main_engine.add_gateway(TapGateway)
|
# main_engine.add_gateway(TapGateway)
|
||||||
|
|
||||||
# main_engine.add_app(CtaStrategyApp)
|
# main_engine.add_app(CtaStrategyApp)
|
||||||
|
@ -957,6 +957,9 @@ class HbdmDataWebsocketApi(HbdmWebsocketApiBase):
|
|||||||
def on_connected(self):
|
def on_connected(self):
|
||||||
""""""
|
""""""
|
||||||
self.gateway.write_log("行情Websocket API连接成功")
|
self.gateway.write_log("行情Websocket API连接成功")
|
||||||
|
|
||||||
|
for ws_symbol in self.ticks.keys():
|
||||||
|
self.subscribe_data(ws_symbol)
|
||||||
|
|
||||||
def subscribe(self, req: SubscribeRequest):
|
def subscribe(self, req: SubscribeRequest):
|
||||||
""""""
|
""""""
|
||||||
@ -979,7 +982,11 @@ class HbdmDataWebsocketApi(HbdmWebsocketApiBase):
|
|||||||
gateway_name=self.gateway_name,
|
gateway_name=self.gateway_name,
|
||||||
)
|
)
|
||||||
self.ticks[ws_symbol] = tick
|
self.ticks[ws_symbol] = tick
|
||||||
|
|
||||||
|
self.subscribe_data(ws_symbol)
|
||||||
|
|
||||||
|
def subscribe_data(self, ws_symbol: str):
|
||||||
|
""""""
|
||||||
# Subscribe to market depth update
|
# Subscribe to market depth update
|
||||||
self.req_id += 1
|
self.req_id += 1
|
||||||
req = {
|
req = {
|
||||||
|
Loading…
Reference in New Issue
Block a user