Skip to content

Atul-Ranjan12/edgekit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

edgekit

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.

Install

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 / lightgbm

import edgekit always works on numpy+pandas alone; heavy deps load lazily only when you call the code that needs them.

The full pipeline

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.

Modules

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

The validation gauntlet

Run in order; stop believing at the first failure.

  1. Causality — indicators are unlagged; you lag() explicitly. Property tests perturb future bars and assert the past doesn't move.
  2. Realistic costsCostModel, gap-aware fills.
  3. Permutation (MCPT)validation.mcpt; p < 0.01.
  4. Walk-forwardvalidation.walk_forward.
  5. Regime splitvalidation.regime_by_year / regime_by_adx.
  6. Cost stress ×1/2/3costs.cost_stress.
  7. Is-it-betavalidation.is_it_beta.
  8. Parameter robustnessvalidation.param_sweep (smooth plateau, not a knife-edge).
  9. Honest forward — haircut ×0.85 (edge decay) × ~0.75 (size-down).

Design

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.

Tests

pytest            # causality, statistical validity, and round-trip tests

The 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).

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages