vectorbt icon indicating copy to clipboard operation
vectorbt copied to clipboard

How to iterate backtest with different combinations of TP and SL?

Open jasonxtrading opened this issue 2 years ago • 2 comments

Hi,

I am trying to make a backtest of a breakout strategy on stocks and would like to find the right combination of TP and SL? I have realised that in vbt.Portfolio.from_signals(close_price,entries,tp_stop = 0.01,sl_stop= 0.005) you cannot give a range of scalars, but only one scalar.

I would like to backtest the strategy with TP target between 0.01 and 0.05 and the same for SL.

Any ideas of how can I go about this?

Thanks in advance.

jasonxtrading avatar Oct 05 '22 06:10 jasonxtrading

there's an example here : https://github.com/polakowo/vectorbt/blob/b5d49438492e442c936c8580d2e1580f1eda5e47/vectorbt/signals/generators.py#L686

httran13 avatar Jan 17 '23 23:01 httran13

@httran13 This only analyze signals before simulation . If I have a Custom IndicatorFactory , is that mean I need create a corresponding SignalFactory to generate sl_stop, tp_stop, wonder if here any convenient way .

Would you share any idea about optimisze sl_stop, tp_stop base on simulation return value (asset_value)?

eromoe avatar Jan 18 '23 08:01 eromoe