[Add] 增加VtTradeData.createFromGateway

This commit is contained in:
nanoric 2018-10-17 05:26:08 -04:00
parent 04068256d3
commit 46dda98d07

View File

@ -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