Backtest results plot break when using yfinance data
Expected Behavior
Plot backtest results using data from yfinance
Actual Behavior
Getting error code
File ~/Documents/git/python.strategy-optimisations/.venv/lib/python3.9/site-packages/backtesting/_plotting.py:148, in _maybe_resample_data.<locals>._group_trades.<locals>.f(s, new_index, bars)
145 if s.size:
146 # Via int64 because on pandas recently broken datetime
147 mean_time = int(bars.loc[s.index].view(int).mean())
--> 148 new_bar_idx = new_index.get_loc(mean_time, method='nearest')
149 return new_bar_idx
TypeError: get_loc() got an unexpected keyword argument 'method'
Steps to Reproduce
Please see the colab link https://colab.research.google.com/drive/1R4JjhkdSi47QQI2gV7QUZXsYzY2-ihrr?usp=sharing
I'm learning to use the library and following the examples in the website which are based on data from GOOG. I wanted to swap the data to BTC from yfinance which works well when running the backtester but it breaks when plotting the chart.
Apart from the index named "Datetime" I can't see any other difference.
same issue here, any update?
same issue here, any uppate?
I believe when there is too much data on the graph to be shown, the data is resampled and then shown (which is the default behaviour), and then I got the same error.
What worked for me was passing bt.plot(resample=False) while plotting the graph.