kernc
kernc
I believe you should have seen this warning printed: https://github.com/kernc/backtesting.py/blob/267d99f0d48745acf98156b2e69150c02d42f761/backtesting/backtesting.py#L1073-L1077 See https://github.com/kernc/backtesting.py/issues/134.
The [recommended approach for trading within candlesticks](https://kernc.github.io/backtesting.py/doc/examples/Quick%20Start%20User%20Guide.html#Strategy) is to obtain/load OHLC data in a lower time-frame.
> a way to specify a `warming_period` as a number of candles to ignore for the plot and stats Done automatically like this for backtest and plots: https://github.com/kernc/backtesting.py/blob/4f21a652d5292f93d5a717cc25f068fd2c35dcc2/backtesting/backtesting.py#L1146-L1149 Therefore, you...
> html output of the plot Basically, you'd like plotted Profit/Loss triangles positioned on y axis in absolute "dollar" units instead of percents? :raised_eyebrow: I'm willing to tie that on...
This breaks in `.mean()`: https://github.com/kernc/backtesting.py/blob/e3cccdfc0fdf8f6f1fe0b5c7b84fd5a2b15fab2d/backtesting/_plotting.py#L113-L118 I'm assuming, is your strategy creating an indicator that is not numeric? Such as: ```py self.I(np.random.choice, ['a', 'b'], len(self.data)) ```
> So the fix is to use `0` or some numerical value for padding. The standard for numeric arrays is [NaN](https://en.wikipedia.org/wiki/NaN): `np.nan`. ----- I think we might want to catch/mitigate...
This is the whole of [`TrailingStrategy`](https://kernc.github.io/backtesting.py/doc/backtesting/lib.html#backtesting.lib.TrailingStrategy): https://github.com/kernc/backtesting.py/blob/1ee5670d03b26680d9add5c96a9f98e44fc722a2/backtesting/lib.py#L406-L450 It should be fairly simple to adapt/duplicate one for percent values.
As a quick workaround, something like this might work: ```py def pct_to_atr(pct: float, data: pd.DataFrame): """Express `pct` change in units of ATR.""" assert 0 < pct < 1 h, l,...
Should be rather easy to invert, something like: ```py def atr_to_pct(n_atr: float, data: pd.DataFrame): """Express `n_atr` in units of ATR as percentage of current price.""" h, l, c_prev = data.High,...
Can you rather show some code? Note, everything prefixed with an underscore is, as customary, private API with no explicit guarantees.