-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Plotted data and printed stats don't match #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The issue is not observed in the simple examples that accompany the distribution. Are you, perchance, using more than: backtesting.py/backtesting/_plotting.py Line 92 in 0a76e96
bars of input data, with some downsampling ( bt.plot(resample=) ) taking place?
There are indeed two different code paths: stats: backtesting.py/backtesting/backtesting.py Line 1594 in 0a76e96
using: backtesting.py/backtesting/backtesting.py Lines 1493 to 1513 in 0a76e96
And plot: backtesting.py/backtesting/_plotting.py Lines 285 to 294 in 0a76e96
backtesting.py/backtesting/_plotting.py Lines 362 to 367 in 0a76e96
I'd consider Appreciate any further investigation you can do. What version is this anyway? Something similar had been fixed in #162. |
Here is the version Thanks for your quick reply - I understand that the issue needs to be investigated on my side, but I created it in case anyone else will experience such. |
It's most likely that the issue is a rounding error that stems from plot resampling ( backtesting.py/backtesting/_plotting.py Lines 186 to 189 in 0a76e96
|
I'm using resampling as above, where Alright, as far as I understood from your response, this is expected behavior due to the resampling taking place. Let me know if I should close the issue. |
I'm fairly confident it's due to brefore-plot resampling. See how trades are resampled and weighted aggregated on the bottom here: backtesting.py/backtesting/_plotting.py Lines 92 to 146 in 0a76e96
Plot trade count is then inferred simply as length of the data frame: backtesting.py/backtesting/_plotting.py Lines 478 to 481 in 0a76e96
Improvements are always welcome! 😁 If you avoid resampling by running: backtest.plot(resample=False, filename="temp2.html") or: backtest.plot(resample=1_000_000, filename="temp2.html") # Some large number you should see values more aligned with those expected. |
Uh oh!
There was an error while loading. Please reload this page.
Max drawdown duration is 273 days from the plot, but 248 days from the stats.
The text was updated successfully, but these errors were encountered: