← ClaudeAtlas

lib-backtesting-pylisted

Single-asset bar-loop backtester with honest next-open fills, an AGPL-3.0 licence, and an indicator API that computes over the entire series before slicing. TRIGGER - from backtesting import Backtest, Strategy; pip install backtesting, bt = Backtest(df, MyStrategy), bt.run(), bt.optimize(), self.I(), self.buy(), self.sell(), self.data.Close, trade_on_close, exclusive_orders, finalize_trades, commission, spread, backtesting.lib crossover, _OutOfMoneyError, "kernc"; wanting a portfolio, a universe or a second instrument inside it. Memory is stale here: it is alive at 0.6.6 (2026-07-22), it is AGPL-3.0-or-later rather than MIT, and trade_on_close fills at data.Close[-2] rather than the current bar's close. SKIP for multi-asset or cross-sectional work and for engine choice generally (backtesting-engines). SKIP when the question is WHICH library to choose, or names no library at all - both belong to the domain skill.
howard-lynn-ye/fin-skills · ★ 1 · Testing & QA · score 77
Install: claude install-skill howard-lynn-ye/fin-skills
# backtesting.py A small, honest bar loop with pessimistic fill logic — and two things people reliably get wrong: the licence, and what `trade_on_close` actually does. | | | |---|---| | pip / import | `pip install backtesting` · `import backtesting` | | Version | **0.6.6 (2026-07-22)** · `>=3.9` · pure-Python `py3-none-any` wheel, no compiler | | Licence | 🚨 **AGPL-3.0-or-later** (declared *and* classified) | | Status | ✅ Active. 8,931★ `kernc/backtesting.py`, pushed 2026-08-05. 🚨 **Single asset. Full stop** | ## The trap that costs you money 🚨 **`Strategy.I` computes the indicator over the FULL series in `init()`, then slices it in `next()`.** For a causal indicator (SMA, EMA, RSI) that is just an optimisation and is fine. For a non-causal one it is a **silent, total leak**: - a centred rolling window - `scipy.signal.filtfilt` or any zero-phase filter - `.shift(-1)`, `.rolling(...).mean().shift(-n)`, a forward-looking `argmax` - a model **fitted on the whole series** and then evaluated pointwise **The framework cannot detect any of these.** No warning, no assertion, no diagnostic — the equity curve simply comes out beautiful. ⚠️ Related residual risk: the loop slices to `i+1` *before* calling `next()`, so `self.data.High[-1]`, `Low[-1]` and `Close[-1]` are all readable inside `next()`. Market-order timing protects your *fills*; it does not stop you reading the current bar's high in a *signal*. ## 🚨 AGPL-3.0 — the most-missed fact about this library Not MIT, not