From 52c4ff2583cb9afb20c4ee3329cf23ef6ce85e7a Mon Sep 17 00:00:00 2001 From: chenxy123 Date: Sun, 3 Apr 2016 14:41:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86vn.trader=E4=B8=ADxs?= =?UTF-8?q?peedGateway=E7=9A=84=E5=87=A0=E4=B8=AAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vn.trader/xspeedGateway/xspeedGateway.py | 48 ++++++++++-------- .../settings/Windows Azure Subscriptions.xml | 2 +- vn.xspeed/vnxspeedtd/vnxspeedtd.opensdf | Bin 58 -> 0 bytes vn.xspeed/vnxspeedtd/vnxspeedtd.v12.suo | Bin 30720 -> 29184 bytes 4 files changed, 27 insertions(+), 23 deletions(-) delete mode 100644 vn.xspeed/vnxspeedtd/vnxspeedtd.opensdf diff --git a/vn.trader/xspeedGateway/xspeedGateway.py b/vn.trader/xspeedGateway/xspeedGateway.py index 13434d37..e365ae53 100644 --- a/vn.trader/xspeedGateway/xspeedGateway.py +++ b/vn.trader/xspeedGateway/xspeedGateway.py @@ -6,6 +6,7 @@ vn.xspeed的gateway接入 import os import json +import time from copy import copy from vnxspeedmd import MdApi @@ -50,6 +51,7 @@ orderStatusMap[STATUS_PARTTRADED] = defineDict["DFITC_SPD_PARTIAL"] orderStatusMap[STATUS_NOTTRADED] = defineDict["DFITC_SPD_IN_QUEUE"] orderStatusMap[STATUS_CANCELLED] = defineDict["DFITC_SPD_CANCELED"] orderStatusMapReverse = {v:k for k,v in orderStatusMap.items()} +orderStatusMapReverse[defineDict["DFITC_SPD_PARTIAL_CANCELED"]] = STATUS_CANCELLED ######################################################################## @@ -422,6 +424,7 @@ class XspeedTdApi(TdApi): self.posDict = {} # 缓存持仓数据的字典 self.orderDict = {} # 缓存委托数据的字典 + self.spdOrderDict = {} # 飞创柜台委托号字典 #---------------------------------------------------------------------- def connect(self, accountID, password, address): @@ -514,7 +517,13 @@ class XspeedTdApi(TdApi): req['accountID'] = self.accountID req['lRequestID'] = self.reqID - self.reqOrderAction(req, self.reqID) + # 添加柜台委托号字段 + localID = int(cancelOrderReq.orderID) + if localID in self.spdOrderDict: + req['spdOrderID'] = self.spdOrderDict[localID] + del req['localOrderID'] + + self.reqCancelOrder(req) #---------------------------------------------------------------------- def close(self): @@ -653,28 +662,17 @@ class XspeedTdApi(TdApi): # 推送 self.gateway.onTrade(trade) + # 获取报单数据对象 + localID = data['localOrderID'] + if localID not in self.orderDict: + return + order = self.orderDict[localID] - # 更新委托信息 - # 创建报单数据对象 - order = VtOrderData() - order.gatewayName = self.gatewayName - - # 保存代码和报单号 - order.symbol = data['instrumentID'] - order.exchange = exchangeMapReverse[data['exchangeID']] - order.vtSymbol = order.symbol - order.orderID = str(data['localOrderID']) - order.vtOrderID = '.'.join([self.gatewayName, order.orderID]) - - order.direction = directionMapReverse.get(data['buySellType'], DIRECTION_UNKNOWN) - order.offset = offsetMapReverse.get(data['openCloseType'], OFFSET_UNKNOWN) order.status = orderStatusMapReverse.get(data['orderStatus'], STATUS_UNKNOWN) - - order.price = data['insertPrice'] - order.totalVolume = data['orderAmount'] + order.tradedVolume += trade.volume # 推送 - self.gateway.onOrder(order) + self.gateway.onOrder(copy(order)) #---------------------------------------------------------------------- def onRtnOrder(self, data) : @@ -682,12 +680,14 @@ class XspeedTdApi(TdApi): # 更新最大报单编号 newLocalID = data['localOrderID'] self.localID = max(self.localID, newLocalID) + self.spdOrderDict[newLocalID] = data['spdOrderID'] # 获取报单数据对象 if newLocalID in self.orderDict: order = self.orderDict[newLocalID] else: order = VtOrderData() + self.orderDict[newLocalID] = order order.gatewayName = self.gatewayName # 保存后续不会变化的数据 @@ -704,7 +704,8 @@ class XspeedTdApi(TdApi): # 价格、报单量等数值 order.price = data['insertPrice'] order.totalVolume = data['orderAmount'] - order.sessionID = data['sessionID'] + order.sessionID = data['sessionID'] + order.orderTime = time.strftime('%H:%M:%S') order.status = orderStatusMapReverse.get(data['orderStatus'], STATUS_UNKNOWN) @@ -723,6 +724,7 @@ class XspeedTdApi(TdApi): order = self.orderDict[newLocalID] else: order = VtOrderData() + self.orderDict[newLocalID] = order order.gatewayName = self.gatewayName # 保存后续不会变化的数据 @@ -756,12 +758,14 @@ class XspeedTdApi(TdApi): # 更新最大报单编号 newLocalID = data['localOrderID'] self.localID = max(self.localID, int(newLocalID)) + self.spdOrderDict[newLocalID] = data['spdOrderID'] # 获取报单数据对象 if newLocalID in self.orderDict: order = self.orderDict[newLocalID] else: order = VtOrderData() + self.orderDict[newLocalID] = order order.gatewayName = self.gatewayName # 保存后续不会变化的数据 @@ -773,11 +777,11 @@ class XspeedTdApi(TdApi): order.vtOrderID = '.'.join([self.gatewayName, order.orderID]) order.direction = directionMapReverse.get(data['buySellType'], DIRECTION_UNKNOWN) - order.offset = offsetMapReverse.get(data['openCloseType'], OFFSET_UNKNOWN) + order.offset = offsetMapReverse.get(data['openClose'], OFFSET_UNKNOWN) order.price = data['insertPrice'] order.totalVolume = data['orderAmount'] - order.sessionID = data['sessionID'] + #order.sessionID = data['sessionID'] order.status = orderStatusMapReverse.get(data['orderStatus'], STATUS_UNKNOWN) order.tradedVolume = data['matchedAmount'] diff --git a/vn.xspeed/vnxspeedtd/Visual Studio 2013/settings/Windows Azure Subscriptions.xml b/vn.xspeed/vnxspeedtd/Visual Studio 2013/settings/Windows Azure Subscriptions.xml index 0568c66a..73e501d2 100644 --- a/vn.xspeed/vnxspeedtd/Visual Studio 2013/settings/Windows Azure Subscriptions.xml +++ b/vn.xspeed/vnxspeedtd/Visual Studio 2013/settings/Windows Azure Subscriptions.xml @@ -1,5 +1,5 @@ - AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAhE4p+D02F0WYPy8qCmMXxAAAAAACAAAAAAAQZgAAAAEAACAAAADdKqCExbfQ0qmV8fAhwxJ3ziOWd8i4kgHKWaahbmhZpwAAAAAOgAAAAAIAACAAAACIs6nje6UjzBQhCRlDYPyT/WvjZ7HWe6fwrCRtdSUF6hAAAABX62nkc+hjHXTxtgPsdkBcQAAAAOlZDGXW8lDNFQGhZ5pLW0aGiuUFyFCyt4EoRQh92KTtiXhOeaxEBfA6MbkxnzyJ4B/ZmwskriS/m0CTVTZFRUY= + AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAhE4p+D02F0WYPy8qCmMXxAAAAAACAAAAAAAQZgAAAAEAACAAAAA6nZeMmbpp7864KoLkSmJz/so1IKtCa7i91O4JJcD6ZwAAAAAOgAAAAAIAACAAAADHPVQMA3OVICvokzgXxWpIA6rD9Yx0fN+YmnHfmx6qSRAAAAD9plAQJWruJsGVioIAbnrYQAAAAAm99ZTmGU9Cx1mka7wlZG54rO9dahDJbcjFFuiJqTB7k9x1zl4uev63L2ecuaFf5swnUTU/VvuczBdubr0ebSs= \ No newline at end of file diff --git a/vn.xspeed/vnxspeedtd/vnxspeedtd.opensdf b/vn.xspeed/vnxspeedtd/vnxspeedtd.opensdf deleted file mode 100644 index 6eb9f3e075b81930ebb5c19140979f9cc6afd2ee..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 58 zcmZ={NMXoj$YjU^;$nsph9ZVUAej%O85lwtf*D*Hf*5oej2H|U3>i#;qy>;|%;3im G$p8Q_!wCui diff --git a/vn.xspeed/vnxspeedtd/vnxspeedtd.v12.suo b/vn.xspeed/vnxspeedtd/vnxspeedtd.v12.suo index cabdc19b24d30f35572c8e345589101b84cf6c8a..4ab2545a73fd27abb38ac042cd35a04eaf6a716a 100644 GIT binary patch delta 1186 zcmb7E&1(};5a0Kjk8ONgqe;`4YT2|krZ&|iN~AQj6+_itvH@=v>_I#fv0$Tk%*{(9 zcE_tId-jlK5&wV$3<_#a9=-Sn2(H))O`O^8wy8+bfgkhcb7$tw+sZdq`O2QARmr8G zBptysM|8T~E~y#9j0b8=_ucJJr+#MFs%@si1O7pg`q3sM(6tNg&^VO))>#mkXShUa z;h0V!_aTluatwI{anzCNQ@u2V`ha8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