From 46dda98d072f03c197fadda123251ae349cb23a6 Mon Sep 17 00:00:00 2001 From: nanoric Date: Wed, 17 Oct 2018 05:26:08 -0400 Subject: [PATCH] =?UTF-8?q?[Add]=20=E5=A2=9E=E5=8A=A0VtTradeData.createFro?= =?UTF-8?q?mGateway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/vtObject.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/vnpy/trader/vtObject.py b/vnpy/trader/vtObject.py index e87ff953..e5ac075f 100644 --- a/vnpy/trader/vtObject.py +++ b/vnpy/trader/vtObject.py @@ -163,7 +163,27 @@ class VtTradeData(VtBaseData): self.price = EMPTY_FLOAT # 成交价格 self.volume = EMPTY_INT # 成交数量 self.tradeTime = EMPTY_STRING # 成交时间 + + #---------------------------------------------------------------------- + @staticmethod + def createFromGateway(gateway, symbol, exchange, tradeID, orderID, direction, tradePrice, tradeVolume): + trade = VtTradeData() + trade.gatewayName = gateway.gatewayName + trade.symbol = symbol + trade.exchange = exchange + trade.vtSymbol = symbol + '.' + exchange + + trade.orderID = orderID + trade.vtOrderID = trade.gatewayName + '.' + trade.tradeID + trade.tradeID = tradeID + trade.vtTradeID = trade.gatewayName + '.' + tradeID + + trade.direction = direction + trade.price = tradePrice + trade.volume = tradeVolume + trade.tradeTime = datetime.now().strftime('%H:%M:%S') + return trade #---------------------------------------------------------------------- @staticmethod def createFromOrderData(order, @@ -174,6 +194,7 @@ class VtTradeData(VtBaseData): trade.gatewayName = order.gatewayName trade.symbol = order.symbol trade.vtSymbol = order.vtSymbol + trade.orderID = order.orderID trade.vtOrderID = order.vtOrderID trade.tradeID = tradeID