Update dataService.py

改变插入数据库中分钟k线时间戳,从分钟结束点改为分钟起始点,和vnpy程序内部以及策略处理一致。
This commit is contained in:
yuanhuei 2018-01-18 19:28:05 +08:00 committed by GitHub
parent f6a2623720
commit bd26888bcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,8 @@ config = open('config.json')
setting = json.load(config)
config.close()
MONGO_HOST = setting['MONGO_HOST']
MONGO_PORT = setting['MONGO_PORT']
SYMBOLS = setting['SYMBOLS']
@ -57,6 +59,18 @@ def generateVtBar(row):
bar.date = str(row['trade_date'])
bar.time = str(row['time']).rjust(6, '0')
#将bar的时间改成提前一分钟
hour=bar.time[0:2]
minute=bar.time[2:4]
sec=bar.time[4:6]
if minute=="00":
minute="59"
hour=str(int(hour)-1).rjust(2,'0')
else:
minute=str(int(minute)-1).rjust(2,'0')
bar.time=hour+minute+sec
bar.datetime = datetime.strptime(' '.join([bar.date, bar.time]), '%Y%m%d %H%M%S')
return bar