vn.py官网
开源量化社区
Member
avatar
加入于:
帖子: 3
声望: 0

from vnpy.trader.rqdata import rqdata_client

from vnpy.trader.database import database_manager

from vnpy.trader.constant import Exchange, Interval

from vnpy.trader.object import HistoryRequest

from datetime import datetime

start_date = datetime(2020,1,1)

end_date = datetime(2020,1,10)

def load_data(req):

data = rqdata_client.query_history(req)

database_manager.save_bar_data(data)

print(f"{req.symbol}历史数据下载完成")


req = HistoryRequest(

symbol = 'btcusdt',

exchange = Exchange('BINANCE'),

start = start_date,

interval = Interval.DAILY,

end = end_date

)

load_data(req)

根据教程来着

数据库和交易所API都没有问题

Member
avatar
加入于:
帖子: 3
声望: 0

Traceback (most recent call last):
File "c:/Users/fy/strategies/load_his_data.py", line 46, in <module>
load_data(req)
File "c:/Users/fy/strategies/load_his_data.py", line 25, in load_data
database_manager.save_bar_data(data)
File "D:\vnstudio\lib\site-packages\vnpy\database\mysql\mysql_database.py", line 140, in save_bar_data
bar = bars[0]
TypeError: 'NoneType' object is not subscriptable

Administrator
avatar
加入于:
帖子: 5108
声望: 295

下载失败了,你的bars对象是个None

© 2015-2019 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3

沪公网安备 31011502017034号