From bd26888bcd5bee3f69051e7de9b58bf31a6453b8 Mon Sep 17 00:00:00 2001 From: yuanhuei <35559668+yuanhuei@users.noreply.github.com> Date: Thu, 18 Jan 2018 19:28:05 +0800 Subject: [PATCH] Update dataService.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改变插入数据库中分钟k线时间戳,从分钟结束点改为分钟起始点,和vnpy程序内部以及策略处理一致。 --- examples/QuantosDataService/dataService.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/QuantosDataService/dataService.py b/examples/QuantosDataService/dataService.py index 470a3e16..4246f6d8 100644 --- a/examples/QuantosDataService/dataService.py +++ b/examples/QuantosDataService/dataService.py @@ -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