VeighNa量化社区
你的开源社区量化交易平台
callingpulse's Avatar
Member
离线
8 帖子
声望: 2

不出意外的话,今天晚上更新, 白天要工作啊..

一不小心催更成功了。哈哈,谢谢楼主的分享。

要想调试vnpy里面的代码,还需要把justMyCode设置成False

"configurations": [
        {
            "name": "Python: 当前文件",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false,
        }
    ]

。。。明天也没看到帖子

2020/09/09更新
原来代码

bar = BarData(

              symbol=row.symbol,
              exchange=row.exchange,
              datetime=row.datetime,#报错的地方,需要增加时区信息
              interval=row.interval,
              volume=row.volume,
              open_price=row.open,
              high_price=row.high,
              low_price=row.low,
              close_price=row.close,
              open_interest=row.open_interest,
              gateway_name="DB",

        )

运行会报错:

AttributeError: 'str' object has no attribute 'astimezone'

原因是新版本vnpy支持了时区数据,所以datetime=row.datetime需要加上时区信息

from datetime import datetime, timedelta, timezone

# 中国时区是+8,对应参数hours=8
# 日本时区是+9,hours=9
utc_8 = timezone(timedelta(hours=8))
datetime=row.datetime.replace(tzinfo=utc_8)

一个小技巧,把bar里面的数据打印出来,看看都是什么格式。

sql_manager.get_oldest_bar_data()
© 2015-2022 微信 18391752892
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

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