You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree to follow this project's Contributing Guidelines
which, I understand, contain short technical notes on how to best contribute to this project.
Own due diligence
I verify my due dilligence—I have went through the tutorials and the API docs and
have used the search on Issues and GitHub Disucussions, as well all Google,
with all the relevant search keywords.
Expected behavior
Hi after downloading the most recent version of Backtesting .py (0.6.1) and running it I noticed material increases in my stats generated. I currently use the backtest module with the trade_on_close set to True (see below). The expected behaviour based on earlier versions is that both the buy (entry price) and sell (exit price) trades are execute using the closing price on the day on which the respective signal is generated.
This functionality had been working as expected in previous versions as I use Backtesting.py to validate my own backtesting code.
After looking at the backtesting.py trades file and comparing this to my own prices dataframe it appears that when I sell/close a position, the price used is the following day's open price not the closing price of the day on which the sell signal was generated. This issue is exasperated due to the fact that in my price file I use adjusted prices for my close prices and all other prices (open, hi, lo) are left unadjusted. The result is that my buy trades are done with adjusted prices and my sales are done with unadjusted prices.
The trade_on_close functionality had been working in previous versions.
Additional info, steps to reproduce, full crash traceback, screenshots
Below are stats run with and without the trade_on_close set to False or True. The "false" setting (left side) appears to be working as both buy and sell trades are executed using the next day open. The "True" (right side) is showing the affect of buy trades done on the close (adjusted prices) and the sell done at the next day open (unadjusted prices).
Contributing guidelines
Contributing Guidelines
which, I understand, contain short technical notes on how to best contribute to this project.
Own due diligence
have used the search on Issues and GitHub Disucussions, as well all Google,
with all the relevant search keywords.
Expected behavior
Hi after downloading the most recent version of Backtesting .py (0.6.1) and running it I noticed material increases in my stats generated. I currently use the backtest module with the trade_on_close set to True (see below). The expected behaviour based on earlier versions is that both the buy (entry price) and sell (exit price) trades are execute using the closing price on the day on which the respective signal is generated.
This functionality had been working as expected in previous versions as I use Backtesting.py to validate my own backtesting code.
Code sample
Actual behavior
After looking at the backtesting.py trades file and comparing this to my own prices dataframe it appears that when I sell/close a position, the price used is the following day's open price not the closing price of the day on which the sell signal was generated. This issue is exasperated due to the fact that in my price file I use adjusted prices for my close prices and all other prices (open, hi, lo) are left unadjusted. The result is that my buy trades are done with adjusted prices and my sales are done with unadjusted prices.
The trade_on_close functionality had been working in previous versions.
Additional info, steps to reproduce, full crash traceback, screenshots
Below are stats run with and without the trade_on_close set to False or True. The "false" setting (left side) appears to be working as both buy and sell trades are executed using the next day open. The "True" (right side) is showing the affect of buy trades done on the close (adjusted prices) and the sell done at the next day open (unadjusted prices).
Trades 99 | | # Trades 99
Win Rate [%] 47.4747 | | Win Rate [%] 76.7677
Best Trade [%] 68.7149 | | Best Trade [%] 72.7316
Worst Trade [%] -18.1411 | | Worst Trade [%] -16.8448
Avg. Trade [%] 2.0143 | | Avg. Trade [%] 6.1904
Max. Trade Duration 357 days 00:00:00 | | Max. Trade Duration 357 days 00:00:00
Avg. Trade Duration 41 days 00:00:00 | | Avg. Trade Duration 41 days 00:00:00
Profit Factor 2.2587 | | Profit Factor 9.7871
Expectancy [%] 2.5082 | | Expectancy [%] 6.7451
SQN 1.4753 | | SQN 1.6812
Kelly Criterion 234.9810m | | Kelly Criterion 520.8895m
_strategy DIY_Signal_Gener... | | _strategy DIY_Signal_Gener...
_equity_curve Eq... | | _equity_curve Eq...
_trades Size EntryB... | | _trades Size Entry...
dtype: object | | dtype: object
Software versions
Currently running Backtesting.py version 0.6.1, Sambo version 1.25.0
The text was updated successfully, but these errors were encountered: