From 981c666f4d7e1061f02d9e7fb5c784c59c2f863e Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 8 Jun 2019 22:34:46 +0800 Subject: [PATCH] [Mod] change to use position summary instead of indvidual position --- vnpy/gateway/tap/tap_gateway.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/vnpy/gateway/tap/tap_gateway.py b/vnpy/gateway/tap/tap_gateway.py index b2030b4c..8baa2173 100644 --- a/vnpy/gateway/tap/tap_gateway.py +++ b/vnpy/gateway/tap/tap_gateway.py @@ -19,7 +19,7 @@ from vnpy.api.tap.vntap.ITapTrade import ( TapAPIApplicationInfo as TapTradeAPIApplicationInfo, TapAPITradeLoginAuth, TapAPIAccQryReq, TapAPIFundReq, TapAPIAccountInfo, TapAPIFundData, - TapAPIPositionQryReq, TapAPIPositionInfo, + TapAPIPositionQryReq, TapAPIPositionSummary, TapAPIOrderQryReq, TapAPIFillQryReq, TapAPIOrderInfo, TapAPIFillInfo, TapAPINewOrder, TapAPIOrderCancelReq, @@ -502,12 +502,12 @@ class TradeApi(ITapTradeAPINotify): """""" self.update_account(info) - def OnRspQryPosition( + def OnRspQryPositionSummary( self, sessionID: int, errorCode: int, isLast: str, - info: TapAPIPositionInfo + info: TapAPIPositionSummary ): if errorCode != TAPIERROR_SUCCEED: self.gateway.write_log(f"查询持仓信息失败") @@ -520,7 +520,7 @@ class TradeApi(ITapTradeAPINotify): self.gateway.write_log(f"查询持仓信息成功") self.query_order() - def OnRtnPosition(self, info: TapAPIPositionInfo): + def OnRtnPositionSummary(self, info: TapAPIPositionSummary): """""" self.update_position(info) @@ -581,7 +581,7 @@ class TradeApi(ITapTradeAPINotify): ) self.gateway.on_account(account) - def update_position(self, info: TapAPIPositionInfo): + def update_position(self, info: TapAPIPositionSummary): """""" position = PositionData( symbol=info.CommodityNo + info.ContractNo, @@ -589,7 +589,6 @@ class TradeApi(ITapTradeAPINotify): direction=DIRECTION_TAP2VT[info.MatchSide], volume=info.PositionQty, price=info.PositionPrice, - pnl=info.PositionProfit, gateway_name=self.gateway_name ) self.gateway.on_position(position) @@ -711,7 +710,7 @@ class TradeApi(ITapTradeAPINotify): def query_position(self): """""" req = TapAPIPositionQryReq() - self.api.QryPosition(req) + self.api.QryPositionSummary(req) def query_order(self): """"""