How to sell_all_shares at the end_date when backtesting
ohfighting opened this issue · comments
Hi,
I found that if i set strategy like below, the winning rate is alway 100%, as losers have alway been held even the backtesting ended, and the losses were not included in the statistics.
Is there any parameter of backtest to avoid this condition, or where i could execute sell_all_shares() at the end_date of backtesting?
if not pos and some conditions:
ctx.buy_shares = ctx.calc_target_shares(0.2)
ctx.stop_profit_pct = 3
elif pos:
do nothing
See the exit_on_last_bar configuration option.