kernc

Results 458 comments of kernc

Currently, only backticked references (i.e. `` `package.module.identifier` ``) are checked. :thinking: Checking arguments in docstrings' Args sections certainly would make an interesting addition. :+1: Care enough to have a go...

It's true that the `adjusted_price` is per-unit and not per-order ... https://github.com/kernc/backtesting.py/blob/d271812c61bf42cb5df93998939109a2b13c578f/backtesting/backtesting.py#L941-L944 https://github.com/kernc/backtesting.py/blob/d271812c61bf42cb5df93998939109a2b13c578f/backtesting/backtesting.py#L829-L834 But applying **percent-based commission is irrespective of the amount**—the percentages are fixed. It's just another multiplier? But...

> Suggested fix: Change the calculation so that the commission is only added once per order Most brokers charge commission per "side" of the trade: once when you open and...

Simply calling [`Strategy.buy()`](https://kernc.github.io/backtesting.py/doc/backtesting/backtesting.html#backtesting.backtesting.Strategy.buy) with `sl=` and `tp=` should do it? ```py self.buy(size=10, limit=limit_price, sl=sl_price, tp=tp_price) ``` ?

At least: > `((self.position.is_long!=True) or (self.position.is_short!=True))` is the erroneous condition. This condition is _always_ true. Prefer: ```py if not self.position: ...

> it's clear that the return Pct comes from the trade volume. > ... in percent relative to trade size.""" If `pl` is the profit or loss of a trade...

> 1. Why the `ta.atr` function doesn't work with `resample_apply`? > AttributeError: 'numpy.ndarray' object has no attribute 'index' Seems to break here: https://github.com/kernc/backtesting.py/blob/b1a869c67feb531f97bef8769aee09d26a5e0288/backtesting/lib.py#L319-L328 Following the logic, I think the inner...

> `ta.atr` comes from `pandas-ta` library. ATR is just a single column What its shape, ndim? It looks like this condition holds: `ta.atr(h, l, c).ndim not in (1, 2)`, whereas...

> As you see the end result is a candlestick that starts at `22:05` but contains datas from `22:00` to `22:04`. This is wrong Thanks for the illustrative example! You...

Well, that's confusing. If the result object is already a Series, [there's no way I see](https://github.com/kernc/backtesting.py/issues/1243#issuecomment-2718163090) for it to crash with `AttributeError: 'numpy.ndarray' object has no attribute 'index'` ... 🤔