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've added a function to close intraday trades at the end of the day, but I'm encountering an issue when running vbt.Portfolio.from_signals(**portfolio_params) with a stop loss. Specifically,
when I set portfolio_params['sl_stop'] = sl_percent / 100 , my trades are being carried over to the next day instead of being closed.
Input Data and Expected Behavior:
My input data is generated by the autoclose_intraday_trades() function, which assigns an exit signal (short) at the end of the day to close the trade. The expected input data looks like this: long, hold, hold, ..., short.
Issue with Stop Loss:
However, when the stop loss is triggered, vbt.Portfolio.from_signals(**portfolio_params) inserts an additional signal into the array, changing it to long, hold, short, ...short . This causes the trade to not be closed correctly, resulting in spillover into the next day.
Actual Behavior:
The trade is not being closed at the end of the day, and the stop loss is not being applied correctly.
Reproduction Steps:
Add a custom function autoclose_intraday_trades() to assign an exit signal at the end of the day.
Run vbt.Portfolio.from_signals(**portfolio_params) with portfolio_params['sl_stop'] = sl_percent / 100.
Observe that trades are being spilled over to the next day when stop loss is triggered.
Request:
I would like to request assistance in resolving this issue. Is there a way to handle this in VBT to ensure proper backtesting for intraday trades? Please provide guidance or a solution to resolve this issue.
The text was updated successfully, but these errors were encountered:
Description:
I've added a function to close intraday trades at the end of the day, but I'm encountering an issue when running
vbt.Portfolio.from_signals(**portfolio_params)
with a stop loss. Specifically,when I set
portfolio_params['sl_stop'] = sl_percent / 100
, my trades are being carried over to the next day instead of being closed.Input Data and Expected Behavior:
My input data is generated by the autoclose_intraday_trades() function, which assigns an exit signal (short) at the end of the day to close the trade. The expected input data looks like this:
long, hold, hold, ..., short
.Issue with Stop Loss:
However, when the stop loss is triggered,
vbt.Portfolio.from_signals(**portfolio_params)
inserts an additional signal into the array, changing it tolong, hold, short, ...short
. This causes the trade to not be closed correctly, resulting in spillover into the next day.Actual Behavior:
The trade is not being closed at the end of the day, and the stop loss is not being applied correctly.
Reproduction Steps:
Add a custom function autoclose_intraday_trades() to assign an exit signal at the end of the day.
Run vbt.Portfolio.from_signals(**portfolio_params) with portfolio_params['sl_stop'] = sl_percent / 100.
Observe that trades are being spilled over to the next day when stop loss is triggered.
Request:
I would like to request assistance in resolving this issue. Is there a way to handle this in VBT to ensure proper backtesting for intraday trades? Please provide guidance or a solution to resolve this issue.
The text was updated successfully, but these errors were encountered: