VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 3
声望: 0

我这边自己合成BarData数据想保存到mysql中去,调用vnpy.trader.database.BaseDatabase.save_bar_data方法报错
请大佬们帮忙看看~
错误信息

Traceback (most recent call last):
  File "D:/PyCharm/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\PyCharm\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/py_workspaces/vnpy/utils/load_from_baostock.py", line 101, in <module>
    load_insert_db('sh.600000', '2022-09-01', '2022-10-01')
  File "D:/py_workspaces/vnpy/utils/load_from_baostock.py", line 53, in load_insert_db
    database.save_bar_data(bar_datas)
  File "C:\ProgramData\Anaconda3\envs\vnpy\lib\site-packages\vnpy_mysql\mysql_database.py", line 180, in save_bar_data
    d["exchange"] = d["exchange"].value
TypeError: 'mappingproxy' object does not support item assignment

代码片段:

database = get_database()
    bar_datas = pd2BarData(df, frequency)
    database.save_bar_data(bar_datas)
Member
avatar
加入于:
帖子: 1641
声望: 119

检查下这里bar_datas是否为一个内部元素为BarData对象的列表吧。

从报错上看这里内部元素是mappingproxy

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

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】