[Add] 增加VtTickData的静态初始化函数
[Fix] 修复一个潜在BUG:仅仅载入vtObject.py并初始化VtLogData时有可能提示INFO字段不存在
This commit is contained in:
parent
eb844d4b9b
commit
e8ded9edf5
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user