diff --git a/examples/CryptoTrader/VT_setting.json b/examples/CryptoTrader/VT_setting.json index 473017fb..40495eca 100644 --- a/examples/CryptoTrader/VT_setting.json +++ b/examples/CryptoTrader/VT_setting.json @@ -9,12 +9,12 @@ "darkStyle": true, "language": "chinese", - "logActive": true, + "logActive": false, "logLevel": "debug", "logConsole": true, "logFile": true, - "tdPenalty": ["IF", "IH", "IC"], + "tdPenalty": [], - "maxDecimal": 4 + "maxDecimal": 10 } \ No newline at end of file diff --git a/vnpy/api/huobi/vnhuobi.py b/vnpy/api/huobi/vnhuobi.py index ca9db9a3..f6b37697 100644 --- a/vnpy/api/huobi/vnhuobi.py +++ b/vnpy/api/huobi/vnhuobi.py @@ -504,8 +504,6 @@ class DataApi(object): self.subDict = {} self.url = '' - self.proxyHost = '' - self.proxyPort = 0 #---------------------------------------------------------------------- def run(self): @@ -532,12 +530,7 @@ class DataApi(object): def reconnect(self): """重连""" try: - if not self.proxyHost: - self.ws = create_connection(self.url) - else: - self.ws = create_connection(self.url, - http_proxy_host=self.proxyHost, - http_proxy_port=self.proxyPort) + self.ws = create_connection(self.url) return True except: msg = traceback.format_exc() @@ -553,20 +546,12 @@ class DataApi(object): self.subTopic(topic) #---------------------------------------------------------------------- - def connect(self, url, proxyHost='', proxyPort=0): + def connect(self, url): """连接""" self.url = url - self.proxyHost = proxyHost - self.proxyPort = proxyPort try: - if not self.proxyHost: - self.ws = create_connection(self.url) - else: - self.ws = create_connection(self.url, - http_proxy_host=self.proxyHost, - http_proxy_port=self.proxyPort) - + self.ws = create_connection(self.url) self.active = True self.thread.start() diff --git a/vnpy/trader/gateway/huobiGateway/huobiGateway.py b/vnpy/trader/gateway/huobiGateway/huobiGateway.py index 2b84a7ee..7e50940c 100644 --- a/vnpy/trader/gateway/huobiGateway/huobiGateway.py +++ b/vnpy/trader/gateway/huobiGateway/huobiGateway.py @@ -75,8 +75,6 @@ class HuobiGateway(VtGateway): accessKey = str(setting['accessKey']) secretKey = str(setting['secretKey']) symbols = setting['symbols'] - proxyHost = str(setting['proxyHost']) - proxyPort = int(setting['proxyPort']) except KeyError: log = VtLogData() log.gatewayName = self.gatewayName @@ -85,7 +83,7 @@ class HuobiGateway(VtGateway): return # 创建行情和交易接口对象 - self.dataApi.connect(exchange, proxyHost, proxyPort) + self.dataApi.connect(exchange, symbols) self.tradeApi.connect(exchange, accessKey, secretKey, symbols) # 初始化并启动查询 @@ -94,7 +92,8 @@ class HuobiGateway(VtGateway): #---------------------------------------------------------------------- def subscribe(self, subscribeReq): """订阅行情""" - self.dataApi.subscribe(subscribeReq) + pass + #self.dataApi.subscribe(subscribeReq) #---------------------------------------------------------------------- def sendOrder(self, orderReq): @@ -179,38 +178,40 @@ class HuobiDataApi(DataApi): self.tickDict = {} - self.subscribeDict = {} + #self.subscribeDict = {} #---------------------------------------------------------------------- - def connect(self, exchange, proxyHost, proxyPort): + def connect(self, exchange, symbols): """连接服务器""" if exchange == 'huobi': url = 'wss://api.huobi.pro/ws' else: url = 'wss://api.hadax.com/ws' + + self.symbols = symbols - if proxyHost: - self.connectionStatus = super(HuobiDataApi, self).connect(url, proxyHost, proxyPort) - else: - self.connectionStatus = super(HuobiDataApi, self).connect(url) + self.connectionStatus = super(HuobiDataApi, self).connect(url) self.gateway.mdConnected = True if self.connectionStatus: self.writeLog(u'行情服务器连接成功') - + + for symbol in self.symbols: + self.subscribe(symbol) # 订阅所有之前订阅过的行情 - for req in self.subscribeDict.values(): - self.subscribe(req) + #for req in self.subscribeDict.values(): + # self.subscribe(req) + #---------------------------------------------------------------------- - def subscribe(self, subscribeReq): + def subscribe(self, symbol): """订阅合约""" - self.subscribeDict[subscribeReq.symbol] = subscribeReq + #self.subscribeDict[subscribeReq.symbol] = subscribeReq if not self.connectionStatus: return - symbol = subscribeReq.symbol + #symbol = subscribeReq.symbol if symbol in self.tickDict: return @@ -354,7 +355,7 @@ class HuobiTradeApi(TradeApi): #self.activeOrderSet = set() # 活动委托集合 #---------------------------------------------------------------------- - def connect(self, exchange, accessKey, secretKey, symbols=''): + def connect(self, exchange, symbols, accessKey, secretKey): """初始化连接""" if not self.connectionStatus: self.symbols = symbols