diff --git a/vnpy/trader/gateway/futuGateway/Futu_connect.json b/vnpy/trader/gateway/futuGateway/Futu_connect.json index d26a492d..723cefb8 100644 --- a/vnpy/trader/gateway/futuGateway/Futu_connect.json +++ b/vnpy/trader/gateway/futuGateway/Futu_connect.json @@ -3,5 +3,5 @@ "port": 11111, "market": "HK", "password": "123123", - "env": 1 + "env": "REAL" } \ No newline at end of file diff --git a/vnpy/trader/gateway/futuGateway/futuGateway.py b/vnpy/trader/gateway/futuGateway/futuGateway.py index d557abcb..f4a5431a 100644 --- a/vnpy/trader/gateway/futuGateway/futuGateway.py +++ b/vnpy/trader/gateway/futuGateway/futuGateway.py @@ -12,14 +12,9 @@ from datetime import datetime from copy import copy import futuquant as ft -from futuquant import (RET_ERROR, RET_OK, PriceRegularMode, +from futuquant import (RET_ERROR, RET_OK, TrdEnv, StockQuoteHandlerBase, OrderBookHandlerBase, TradeOrderHandlerBase, TradeDealHandlerBase) - -#from futuquant.open_context import (RET_ERROR, RET_OK, PriceRegularMode, - #StockQuoteHandlerBase, OrderBookHandlerBase, - #USTradeOrderHandlerBase, USTradeDealHandlerBase, - #HKTradeOrderHandlerBase, HKTradeDealHandlerBase) from vnpy.trader.vtGateway import * from vnpy.trader.vtConstant import GATEWAYTYPE_INTERNATIONAL @@ -182,15 +177,11 @@ class FutuGateway(VtGateway): # 连接交易接口 if self.market == 'US': self.tradeCtx = ft.OpenUSTradeContext(self.host, self.port) - OrderHandlerBase = USTradeOrderHandlerBase - DealHandlerBase = USTradeDealHandlerBase else: self.tradeCtx = ft.OpenHKTradeContext(self.host, self.port) - OrderHandlerBase = HKTradeOrderHandlerBase - DealHandlerBase = HKTradeDealHandlerBase - + # 继承实现处理器类 - class OrderHandler(OrderHandlerBase): + class OrderHandler(TradeOrderHandlerBase): """委托处理器""" gateway = self # 缓存Gateway对象 @@ -201,7 +192,7 @@ class FutuGateway(VtGateway): self.gateway.processOrder(content) return RET_OK, content - class DealHandler(DealHandlerBase): + class DealHandler(TradeDealHandlerBase): """订单簿处理器""" gateway = self @@ -223,11 +214,6 @@ class FutuGateway(VtGateway): # 启动交易接口 self.tradeCtx.start() - # 订阅委托推送 - self.tradeCtx.subscribe_order_deal_push([], - order_deal_push=True, - envtype=self.env) - self.writeLog(u'交易接口连接成功') #---------------------------------------------------------------------- @@ -306,7 +292,7 @@ class FutuGateway(VtGateway): #---------------------------------------------------------------------- def qryAccount(self): """查询账户资金""" - code, data = self.tradeCtx.accinfo_query(self.env) + code, data = self.tradeCtx.accinfo_query(trd_env=self.env, acc_id=0) if code: self.writeError(code, u'查询账户资金失败:%s' %data) @@ -327,7 +313,7 @@ class FutuGateway(VtGateway): #---------------------------------------------------------------------- def qryPosition(self): """查询持仓""" - code, data = self.tradeCtx.position_list_query(envtype=self.env) + code, data = self.tradeCtx.position_list_query(trd_env=self.env, acc_id=0) if code: self.writeError(code, u'查询持仓失败:%s' %data) @@ -356,7 +342,7 @@ class FutuGateway(VtGateway): #---------------------------------------------------------------------- def qryOrder(self): """查询委托""" - code, data = self.tradeCtx.order_list_query("", envtype=self.env) + code, data = self.tradeCtx.order_list_query("", trd_env=self.env) if code: self.writeError(code, u'查询委托失败:%s' %data) diff --git a/vnpy/trader/uiBasicWidget.py b/vnpy/trader/uiBasicWidget.py index 4cde79f1..138e9ccf 100644 --- a/vnpy/trader/uiBasicWidget.py +++ b/vnpy/trader/uiBasicWidget.py @@ -1144,7 +1144,7 @@ class ContractMonitor(BasicMonitor): """显示所有合约数据""" l = self.mainEngine.getAllContracts() d = {'.'.join([contract.exchange, contract.symbol]):contract for contract in l} - l2 = d.keys() + l2 = list(d.keys()) l2.sort(reverse=True) self.setRowCount(len(l2))