lib-backtesting-pylisted
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