[Fix] bug when close TapGateway

This commit is contained in:
vn.py 2019-06-22 23:34:53 +08:00
parent e44ad6955c
commit 7682749bba
2 changed files with 12 additions and 10 deletions

View File

@ -11,7 +11,7 @@ from vnpy.gateway.ctp import CtpGateway
# from vnpy.gateway.ctptest import CtptestGateway
from vnpy.gateway.femas import FemasGateway
from vnpy.gateway.tiger import TigerGateway
from vnpy.gateway.oes import OesGateway
# from vnpy.gateway.oes import OesGateway
from vnpy.gateway.okex import OkexGateway
from vnpy.gateway.huobi import HuobiGateway
from vnpy.gateway.bitfinex import BitfinexGateway
@ -19,7 +19,7 @@ from vnpy.gateway.onetoken import OnetokenGateway
from vnpy.gateway.okexf import OkexfGateway
# from vnpy.gateway.xtp import XtpGateway
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.csv_loader import CsvLoaderApp
@ -45,7 +45,7 @@ def main():
main_engine.add_gateway(FutuGateway)
main_engine.add_gateway(BitmexGateway)
main_engine.add_gateway(TigerGateway)
main_engine.add_gateway(OesGateway)
# main_engine.add_gateway(OesGateway)
main_engine.add_gateway(OkexGateway)
main_engine.add_gateway(HuobiGateway)
main_engine.add_gateway(BitfinexGateway)
@ -53,7 +53,7 @@ def main():
main_engine.add_gateway(OkexfGateway)
main_engine.add_gateway(HbdmGateway)
# main_engine.add_gateway(XtpGateway)
# main_engine.add_gateway(TapGateway)
main_engine.add_gateway(TapGateway)
main_engine.add_app(CtaStrategyApp)
main_engine.add_app(CtaBacktesterApp)

View File

@ -336,9 +336,10 @@ class QuoteApi(ITapQuoteAPINotify):
"""
Release TAP API resources.
"""
self.api.SetAPINotify(None)
FreeTapQuoteAPI(self.api)
self.api = None
if self.api:
self.api.SetAPINotify(None)
FreeTapQuoteAPI(self.api)
self.api = None
def subscribe(self, req: SubscribeRequest):
"""
@ -813,9 +814,10 @@ class TradeApi(ITapTradeAPINotify):
"""
Release TAP API resources.
"""
self.api.SetAPINotify(None)
FreeITapTradeAPI(self.api)
self.api = None
if self.api:
self.api.SetAPINotify(None)
FreeITapTradeAPI(self.api)
self.api = None
def parse_datetime(dt_str: str):