diff --git a/examples/FutuTrader/Futu_connect.json b/examples/FutuTrader/Futu_connect.json index 0d756707..6af766f1 100644 --- a/examples/FutuTrader/Futu_connect.json +++ b/examples/FutuTrader/Futu_connect.json @@ -1,7 +1,7 @@ { "host": "127.0.0.1", "port": 11111, - "market": "US", - "password": "123123", + "market": "HK", + "password": "321321", "env": "REAL" } \ No newline at end of file diff --git a/examples/README.md b/examples/README.md index ef046ab8..17b7e8bd 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,12 +2,14 @@ 本文件夹中的内容主要是关于如何在交易业务中使用vn.py的示例 -* VnTrader:最常用的vn.py图形交易界面 +* VnTrader:最常用的vn.py图形交易系统 * OptionMaster: 期权量化交易系统 * WebTrader:使用Web前端作为监控的交易系统 +* FutuTrader:针对富途证券futuquant的交易系统(只支持Python 3) + * DataRecording:全自动行情记录工具(无需用户每日定时重启) * CtaTrading:无图形界面模式的CTA策略交易 diff --git a/vnpy/trader/gateway/futuGateway/futuGateway.py b/vnpy/trader/gateway/futuGateway/futuGateway.py index 96aef1b9..85491b2a 100644 --- a/vnpy/trader/gateway/futuGateway/futuGateway.py +++ b/vnpy/trader/gateway/futuGateway/futuGateway.py @@ -202,8 +202,11 @@ class FutuGateway(VtGateway): return RET_OK, content # 只有港股实盘交易才需要解锁 - if self.market == 'HK' and self.env == TrdEnv.REAL: - self.tradeCtx.unlock_trade(self.password) + code, data = self.tradeCtx.unlock_trade(self.password) + if code == RET_OK: + self.writeLog(u'交易接口解锁成功') + else: + self.writeLog(u'交易接口解锁失败,原因:%s' %data) # 设置回调处理对象 self.tradeCtx.set_handler(OrderHandler()) @@ -474,9 +477,10 @@ class FutuGateway(VtGateway): """处理委托推送""" for ix, row in data.iterrows(): # 如果状态是已经删除,则直接忽略 - if str(row['status']) == '7': + if row['order_status'] == OrderStatus.DELETED: continue + print(row['order_status']) order = VtOrderData() order.gatewayName = self.gatewayName @@ -500,7 +504,7 @@ class FutuGateway(VtGateway): def processDeal(self, data): """处理成交推送""" for ix, row in data.iterrows(): - tradeID = row['deal_id'] + tradeID = str(row['deal_id']) if tradeID in self.tradeSet: continue self.tradeSet.add(tradeID)