Skip to content

Commit

Permalink
[Fix]添加缺失的future库安装
Browse files Browse the repository at this point in the history
  • Loading branch information
vnpy-dev-01 committed Dec 8, 2017
1 parent 3c03099 commit 739364e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
24 changes: 12 additions & 12 deletions examples/QuantosDataService/dataService.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,25 @@ def generateVtBar(row):
return bar

#----------------------------------------------------------------------
def downMinuteBarBySymbol(api, vtSymbol, startDate):
def downMinuteBarBySymbol(api, vtSymbol, startDate, endDate=''):
"""下载某一合约的分钟线数据"""
start = time()

cl = db[vtSymbol]
cl.ensure_index([('datetime', ASCENDING)], unique=True) # 添加索引

dt = datetime.strptime(startDate, '%Y%m%d')
today = datetime.now()

if endDate:
end = datetime.strptime(endDate, '%Y%m%d')
else:
end = datetime.now()
delta = timedelta(1)

code, exchange = vtSymbol.split('.')
symbol = '.'.join([code, exchangeMap[exchange]])

while dt <= today:
while dt <= end:
d = int(dt.strftime('%Y%m%d'))
df, msg = api.bar(symbol, freq='1M', trade_date=d)
dt += delta
Expand All @@ -91,20 +95,20 @@ def downMinuteBarBySymbol(api, vtSymbol, startDate):
cl.replace_one(flt, d, True)


end = time()
cost = (end - start) * 1000
e = time()
cost = (e - start) * 1000

print u'合约%s数据下载完成%s - %s,耗时%s毫秒' %(vtSymbol, startDate, today.strftime('%Y%m%d'), cost)
print u'合约%s数据下载完成%s - %s,耗时%s毫秒' %(vtSymbol, startDate, end.strftime('%Y%m%d'), cost)


#----------------------------------------------------------------------
def downloadAllMinuteBar(api):
def downloadAllMinuteBar(api, days=10):
"""下载所有配置中的合约的分钟线数据"""
print '-' * 50
print u'开始下载合约分钟线数据'
print '-' * 50

startDt = datetime.today() - 10 * timedelta(1)
startDt = datetime.today() - days * timedelta(1)
startDate = startDt.strftime('%Y%m%d')

# 添加下载任务
Expand All @@ -115,7 +119,3 @@ def downloadAllMinuteBar(api):
print u'合约分钟线数据下载完成'
print '-' * 50


if __name__ == '__main__':
downloadAllMinuteBar()

2 changes: 1 addition & 1 deletion examples/QuantosDataService/downloadData.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
print u'数据服务器登录失败,原因:%s' %msg

# 下载数据
downloadAllMinuteBar(api)
downloadAllMinuteBar(api, 100)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ msgpack-python
qdarkstyle
SortedContainers
futuquant
wmi
wmi
future

0 comments on commit 739364e

Please sign in to comment.