[Fix]添加缺失的future库安装

This commit is contained in:
vn.py 2017-12-08 21:23:42 +08:00
parent 3c0309993d
commit 739364ebfe
3 changed files with 15 additions and 14 deletions

View File

@ -62,7 +62,7 @@ def generateVtBar(row):
return bar
#----------------------------------------------------------------------
def downMinuteBarBySymbol(api, vtSymbol, startDate):
def downMinuteBarBySymbol(api, vtSymbol, startDate, endDate=''):
"""下载某一合约的分钟线数据"""
start = time()
@ -70,13 +70,17 @@ def downMinuteBarBySymbol(api, vtSymbol, startDate):
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
@ -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')
# 添加下载任务
@ -115,7 +119,3 @@ def downloadAllMinuteBar(api):
print u'合约分钟线数据下载完成'
print '-' * 50
if __name__ == '__main__':
downloadAllMinuteBar()

View File

@ -19,4 +19,4 @@ if __name__ == '__main__':
print u'数据服务器登录失败,原因:%s' %msg
# 下载数据
downloadAllMinuteBar(api)
downloadAllMinuteBar(api, 100)

View File

@ -5,3 +5,4 @@ qdarkstyle
SortedContainers
futuquant
wmi
future