首页 > 其他分享 >Backtrader - AttributeError: 'OptReturn' object has no attribute 'datas'

Backtrader - AttributeError: 'OptReturn' object has no attribute 'datas'

时间:2023-10-12 15:56:07浏览次数:40  
标签:plot no attribute object True datas

1.0 Error

Traceback (most recent call last):
  File "D:/PycharmProjects/dbpower.backtrader.001/app/main_machine_learning.py", line 191, in <module>
    img = cerebro.plot(style='line', plotdist=0.1, grid=True)
  File "D:\PycharmProjects\dbpower.backtrader.001\app\venv\lib\site-packages\backtrader\cerebro.py", line 991, in plot
    start=start, end=end, use=use)
  File "D:\PycharmProjects\dbpower.backtrader.001\app\venv\lib\site-packages\backtrader\plot\plot.py", line 119, in plot
    if not strategy.datas:
AttributeError: 'OptReturn' object has no attribute 'datas'

  'OptReturn' object has no attribute 'datas'

 

2.0 Fix

cerebro = bt.Cerebro(stdstats=True, cheat_on_open=True, optreturn=True)

  optreturn=True

标签:plot,no,attribute,object,True,datas
From: https://www.cnblogs.com/chenkuang/p/17759684.html

相关文章