From aed035cd6dd7d0662010ae5fba73c0a080f3bfec Mon Sep 17 00:00:00 2001 From: Yohoman <36256482+Yohoman@users.noreply.github.com> Date: Tue, 13 Feb 2018 16:35:47 +0800 Subject: [PATCH] Update dataService.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改原来的cl = db[vtSymbol],为不带交易所名称的cl = db[code],策略才能从MongoDB中读取相应合约的数据。 --- examples/QuantosDataService/dataService.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/QuantosDataService/dataService.py b/examples/QuantosDataService/dataService.py index 2571f871..1de39f2e 100644 --- a/examples/QuantosDataService/dataService.py +++ b/examples/QuantosDataService/dataService.py @@ -84,8 +84,9 @@ def generateVtBar(row): def downMinuteBarBySymbol(api, vtSymbol, startDate, endDate=''): """下载某一合约的分钟线数据""" start = time() - - cl = db[vtSymbol] + + code, exchange = vtSymbol.split('.') + cl = db[code] cl.ensure_index([('datetime', ASCENDING)], unique=True) # 添加索引 dt = datetime.strptime(startDate, '%Y%m%d') @@ -96,7 +97,6 @@ def downMinuteBarBySymbol(api, vtSymbol, startDate, endDate=''): end = datetime.now() delta = timedelta(1) - code, exchange = vtSymbol.split('.') symbol = '.'.join([code, exchangeMap[exchange]]) while dt <= end: