[Mod]完成futuGateway的测试

This commit is contained in:
vn.py 2018-07-23 15:39:00 +08:00
parent 65ed41fcf5
commit 384eb71b28
3 changed files with 13 additions and 7 deletions

View File

@ -1,7 +1,7 @@
{ {
"host": "127.0.0.1", "host": "127.0.0.1",
"port": 11111, "port": 11111,
"market": "US", "market": "HK",
"password": "123123", "password": "321321",
"env": "REAL" "env": "REAL"
} }

View File

@ -2,12 +2,14 @@
本文件夹中的内容主要是关于如何在交易业务中使用vn.py的示例 本文件夹中的内容主要是关于如何在交易业务中使用vn.py的示例
* VnTrader最常用的vn.py图形交易界面 * VnTrader最常用的vn.py图形交易系统
* OptionMaster: 期权量化交易系统 * OptionMaster: 期权量化交易系统
* WebTrader使用Web前端作为监控的交易系统 * WebTrader使用Web前端作为监控的交易系统
* FutuTrader针对富途证券futuquant的交易系统只支持Python 3
* DataRecording全自动行情记录工具无需用户每日定时重启 * DataRecording全自动行情记录工具无需用户每日定时重启
* CtaTrading无图形界面模式的CTA策略交易 * CtaTrading无图形界面模式的CTA策略交易

View File

@ -202,8 +202,11 @@ class FutuGateway(VtGateway):
return RET_OK, content return RET_OK, content
# 只有港股实盘交易才需要解锁 # 只有港股实盘交易才需要解锁
if self.market == 'HK' and self.env == TrdEnv.REAL: code, data = self.tradeCtx.unlock_trade(self.password)
self.tradeCtx.unlock_trade(self.password) if code == RET_OK:
self.writeLog(u'交易接口解锁成功')
else:
self.writeLog(u'交易接口解锁失败,原因:%s' %data)
# 设置回调处理对象 # 设置回调处理对象
self.tradeCtx.set_handler(OrderHandler()) self.tradeCtx.set_handler(OrderHandler())
@ -474,9 +477,10 @@ class FutuGateway(VtGateway):
"""处理委托推送""" """处理委托推送"""
for ix, row in data.iterrows(): for ix, row in data.iterrows():
# 如果状态是已经删除,则直接忽略 # 如果状态是已经删除,则直接忽略
if str(row['status']) == '7': if row['order_status'] == OrderStatus.DELETED:
continue continue
print(row['order_status'])
order = VtOrderData() order = VtOrderData()
order.gatewayName = self.gatewayName order.gatewayName = self.gatewayName
@ -500,7 +504,7 @@ class FutuGateway(VtGateway):
def processDeal(self, data): def processDeal(self, data):
"""处理成交推送""" """处理成交推送"""
for ix, row in data.iterrows(): for ix, row in data.iterrows():
tradeID = row['deal_id'] tradeID = str(row['deal_id'])
if tradeID in self.tradeSet: if tradeID in self.tradeSet:
continue continue
self.tradeSet.add(tradeID) self.tradeSet.add(tradeID)