soltrade icon indicating copy to clipboard operation
soltrade copied to clipboard

Update backtrader

Open GiorgosK opened this issue 11 months ago • 1 comments

Have tried to run the back the backtest.py but it was complaining about matplotlib

❯❯ python testing/backtest.py 
Traceback (most recent call last):
  File "/home/soltrade/testing/backtest.py", line 54, in <module>
    cerebro.plot()
  File "/home/soltrade/.venv/lib/python3.12/site-packages/backtrader/cerebro.py", line 974, in plot
    from . import plot
  File "/home/soltrade/.venv/lib/python3.12/site-packages/backtrader/plot/__init__.py", line 42, in <module>
    from .plot import Plot, Plot_OldSync
  File "/home/soltrade/.venv/lib/python3.12/site-packages/backtrader/plot/plot.py", line 44, in <module>
    from . import locator as loc
  File "/home/soltrade/.venv/lib/python3.12/site-packages/backtrader/plot/locator.py", line 35, in <module>
    from matplotlib.dates import (HOURS_PER_DAY, MIN_PER_HOUR, SEC_PER_MIN,
ImportError: cannot import name 'warnings' from 'matplotlib.dates' (/home/soltrade/.venv/lib/python3.12/site-packages/matplotlib/dates.py)

updating to the latest version of backtrader works I am running Python 3.12.3

Also Backtest.py needed update as the check for stoploss takeprofit were only check when there was no open position

GiorgosK avatar Feb 16 '25 06:02 GiorgosK

I'm going to try to look over everything this week and hopefully get this pull request merged.

nmweaver avatar Mar 09 '25 22:03 nmweaver