From e8ded9edf5ff9cf1ebf9377514b9fbacf30c9016 Mon Sep 17 00:00:00 2001 From: nanoric Date: Tue, 16 Oct 2018 05:46:57 -0400 Subject: [PATCH] =?UTF-8?q?[Add]=20=E5=A2=9E=E5=8A=A0VtTickData=E7=9A=84?= =?UTF-8?q?=E9=9D=99=E6=80=81=E5=88=9D=E5=A7=8B=E5=8C=96=E5=87=BD=E6=95=B0?= =?UTF-8?q?=20[Fix]=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E6=BD=9C?= =?UTF-8?q?=E5=9C=A8BUG=EF=BC=9A=E4=BB=85=E4=BB=85=E8=BD=BD=E5=85=A5vtObje?= =?UTF-8?q?ct.py=E5=B9=B6=E5=88=9D=E5=A7=8B=E5=8C=96VtLogData=E6=97=B6?= =?UTF-8?q?=E6=9C=89=E5=8F=AF=E8=83=BD=E6=8F=90=E7=A4=BAINFO=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E4=B8=8D=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/vtObject.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/vnpy/trader/vtObject.py b/vnpy/trader/vtObject.py index 1a844183..e87ff953 100644 --- a/vnpy/trader/vtObject.py +++ b/vnpy/trader/vtObject.py @@ -1,8 +1,9 @@ # encoding: UTF-8 +from logging import INFO + import time from datetime import datetime -from logging import INFO from vnpy.trader.language import constant from vnpy.trader.vtConstant import (EMPTY_FLOAT, EMPTY_INT, EMPTY_STRING, EMPTY_UNICODE) @@ -74,8 +75,37 @@ class VtTickData(VtBaseData): self.askVolume2 = EMPTY_INT self.askVolume3 = EMPTY_INT self.askVolume4 = EMPTY_INT - self.askVolume5 = EMPTY_INT + self.askVolume5 = EMPTY_INT + #---------------------------------------------------------------------- + @staticmethod + def createFromGateway(gateway, symbol, exchange, + lastPrice, lastVolume, + highPrice, lowPrice, + openPrice=EMPTY_FLOAT, + openInterest=EMPTY_INT, + upperLimit=EMPTY_FLOAT, + lowerLimit=EMPTY_FLOAT): + tick = VtTickData() + tick.gatewayName = gateway.gatewayName + tick.symbol = symbol + tick.exchange = exchange + tick.vtSymbol = symbol + '.' + exchange + + tick.lastPrice = lastPrice + tick.lastVolume = lastVolume + tick.openInterest = openInterest + tick.datetime = datetime.now() + tick.date = tick.datetime.strftime('%Y%m%d') + tick.time = tick.datetime.strftime('%H:%M:%S') + + tick.openPrice = openPrice + tick.highPrice = highPrice + tick.lowPrice = lowPrice + tick.upperLimit = upperLimit + tick.lowerLimit = lowerLimit + return tick + ######################################################################## class VtBarData(VtBaseData):