edgekit

API reference

Every public symbol in edgekit v0.1.0, module by module. Signatures, defaults, and return shapes are copied faithfully from the source — the pages below are generated against the same ground-truth reference the library is tested to.

edgekit is organised as fourteen submodules that map one-to-one onto the research pipeline: load → backtest → prove-or-kill → size → ship. Each has a focused job and a small public surface. The tables below link to the per-module reference; start with core if you want the vocabulary the rest of the library speaks.

The import convention#

There is exactly one supported way to reach everything: import edgekit as ek. The top-level package re-exports every submodule plus the handful of symbols you touch constantly, so you rarely write a deep import.

convention.py
import edgekit as ek

# submodules hang off the package
bars   = ek.data.load_bars("US100_M1.csv")
rth    = bars[ek.data.rth_mask(bars.index)]
trades = ek.strategy.ORB(or_bars=30, target_r=2.0).backtest(rth, warmup=5, bars_per_day=390)

# hot symbols are re-exported at the top level
st = ek.trade_stats(trades.r, dates=trades.date)   # == ek.metrics.trade_stats
p  = ek.validation.mcpt(real_stat, null_fn, n=1000)

The convenience re-exports available as edgekit.<name> are: the submodules challenge, core, costs, data, engine, indicators, metrics, ml, portfolio, report, sizing, strategy, validation, viz; and the symbols OHLC, Signal, Trade, as_ohlc, lag, trades_to_frame, EntryIntent, run_bar_loop, run_backtest, CostModel, cost_stress, trade_stats, equity_stats, max_drawdown, profit_factor, sharpe, sortino, dd_matched_size.

Lean core, lazy heavy deps
import edgekit needs only numpy + pandas. The heavy dependencies are optional extras, imported lazily inside the functions that use them, so importing the package never pays for a chart library you did not call: [viz] (matplotlib), [ml] (scikit-learn / xgboost / lightgbm), [io] (pyarrow). A missing extra raises a clear pip install edgekit[...] pointer, not an obscure ImportError at the top of a run.

The fourteen modules#

ModuleWhat it does
coreR-multiple + OHLC contract, the causal lag() primitive, Signal/Trade dataclasses, seeded RNG
dataLoad / fetch / resample bars, DST-correct sessions, integrity report, chronological split, parquet cache
indicatorsVectorised, unlagged indicators: atr, adx, donchian, rsi, hawkes, rolling hedge, half-life, cross-sectional rank
engineTwo causal backtest engines: run_bar_loop (research) + run_backtest (fixed-RR prop-firm) and the Strategy protocol
costsTransaction-cost models (fraction-of-price & pips) and the cost_stress harness
metricstrade_stats / equity_stats / dd_matched_size, plus profit_factor, drawdown, sharpe, sortino
sizingrisk_parity, hrp, vol_target, size_to_dd, cppi, dd_throttle — R-streams to a dollar equity path
validationThe gauntlet: permutation MCPT, PBO, deflated Sharpe, walk-forward, is-it-beta, block-bootstrap DD
strategyThe strategy zoo: ORB, Keltner, RSI2MeanReversion, StatArbPairs, Hawkes
portfolioCombine validated books into one daily-R stream, correlation, allocation sweep
challengeMonte-Carlo prop-firm simulator: pass-rate + days-to-pass for FTMO / CFT / BrightFunded
vizmatplotlib chart vocabulary + themes, base64-inlined
reportSelf-contained, zero-network HTML reports
mlTriple-barrier labels, purged/embargoed walk-forward, meta-labeling, cloud-safe tree export

Dependency layering#

The modules form a strict layering — later layers import earlier ones, never the reverse. Reading in this order is also the fastest way to understand the library:

  • Foundation. core defines the contracts; data, indicators, and costs all build on it and on nothing else in edgekit.
  • Execution. engine consumes core + costs to run a strategy causally; strategy implements the interface the engine polls.
  • Measurement. metrics summarises trade/equity streams; validation tries to break them.
  • Deployment. sizing and portfolio turn R-streams into dollars; challenge stress-tests the sized path; viz and report present it.
Prime directive
The API surface exists to serve one goal: assume every edge is fake until proven otherwise. The modules you will spend most of your time in are validation and costs — the ones whose job is to disprove your backtest before the market does.

See also#