A systematic-trading research toolkit: load → backtest → prove-or-kill → size → ship.
Prime directive: assume every edge is fake until proven otherwise. Your job is to disprove your own strategy — what survives is real.
edgekit is the reusable core extracted from a large quant-research repo. It replaces
~280 copy-pasted research scripts with one installable, tested library: the same
indicator (hawkes) that was pasted 52 times, the trade-stats builder pasted ~47
times, the permutation test ~60 times — each now lives in exactly one place, with tests.
pip install -e ".[all]" # everything (viz + ml + io + dev)
pip install -e . # lean core: numpy + pandas only
pip install -e ".[viz]" # + matplotlib (charts/reports)
pip install -e ".[ml]" # + scikit-learn / xgboost / lightgbmimport edgekit always works on numpy+pandas alone; heavy deps load lazily only when
you call the code that needs them.
import edgekit as ek
# 1. load + resample
bars = ek.data.load_bars("ohlcv.csv")
bars = ek.data.resample_ohlcv(bars, "4h")
# 2. causal backtest — an illustrative template strategy
trades = ek.strategy.SmaCross().backtest(bars)
stats = ek.trade_stats(trades.r, dates=trades.date) # PF, MAR, EV, Sharpe...
# 3. PROVE it — Monte-Carlo permutation test (p < 0.01 = real edge)
p = ek.validation.mcpt(trades.r.sum(), null_stat, n=1000)
# 4. size to a prop-firm drawdown budget (10% max / 5% daily)
sized = ek.sizing.size_to_dd(daily_r, dd_budget=0.095, account=100_000, daily_cap=0.045)
# 5. simulate the challenge + report
rate = ek.challenge.simulate(daily_pnl, ek.challenge.BRIGHTFUNDED)
ek.report.Report("Strategy").kpi_row(cards).write("report.html")The bundled strategies (ORB, SmaCross) are deliberately plain, illustrative
templates — they exist to exercise the engine and the gauntlet end-to-end, not as tuned
edges. Bring your own strategy by subclassing edgekit.strategy.BaseStrategy.
| Module | What it does |
|---|---|
core |
R-multiple + OHLC contract, lag(), Signal/Trade, reproducible RNG |
data |
load/fetch/resample/RTH-sessions/integrity/stitch/cache/splits |
indicators |
atr · adx · donchian · hawkes · rsi · zscore · rolling-OLS hedge · half-life |
engine |
run_bar_loop (R workhorse + Strategy interface) · run_backtest (prop-firm) |
costs |
CostModel (fraction & pips) · cost_stress ×1/2/3 |
metrics |
trade_stats · equity_stats · sharpe/sortino/pf/max_dd/mar · dd-matched sizing |
sizing |
risk_parity · hrp · vol_target · cppi · dd_throttle · size_to_dd |
validation |
the gauntlet — permutation · pbo/cscv · deflated-sharpe · walk-forward · is-it-beta |
strategy |
BaseStrategy ABC + illustrative templates (ORB · SmaCross) |
portfolio |
book combination · allocation sweep + OOS · correlation |
challenge |
prop-firm simulator (FTMO / CFT / BrightFunded) · pass-rate · days-to-pass |
viz / report |
matplotlib charts + themes · self-contained HTML reports |
ml |
features · triple-barrier labels · purged walk-forward · models · cloud-safe tree export |
Run in order; stop believing at the first failure.
- Causality — indicators are unlagged; you
lag()explicitly. Property tests perturb future bars and assert the past doesn't move. - Realistic costs —
CostModel, gap-aware fills. - Permutation (MCPT) —
validation.mcpt;p < 0.01. - Walk-forward —
validation.walk_forward. - Regime split —
validation.regime_by_year/regime_by_adx. - Cost stress ×1/2/3 —
costs.cost_stress. - Is-it-beta —
validation.is_it_beta. - Parameter robustness —
validation.param_sweep(smooth plateau, not a knife-edge). - Honest forward — haircut ×0.85 (edge decay) × ~0.75 (size-down).
See docs/ARCHITECTURE.md and docs/BUILD_CONTRACT.md.
A standalone, installable library. R-multiple is the currency; causality is a tested
property; core stays numpy+pandas.
pytest # causality, statistical validity, and round-trip testsThe load-bearing ones: causality property tests (perturb future bars, assert the past doesn't move), no-edge-gives-non-significant-p (the gauntlet refuses to bless noise), and tree-export round-trip (cloud-safe cBot inference matches sklearn within 1e-6).