Backtesting & risk#

Turn signals into costed equity curves, and measure drawdown and performance.

Risk & performance#

Drawdowns and performance ratios.

Function

Description

Drawdown

Running drawdown from the cumulative peak.

Maximum drawdown

Worst drawdown experienced so far (since reset).

Rolling Calmar ratio

Annualised return divided by the worst rolling drawdown.

Rolling Conditional Value-at-Risk (Expected Shortfall)

Historical Conditional Value-at-Risk (Expected Shortfall): the mean loss in the worst alpha tail over a window.

Rolling Downside Deviation

Trailing-window downside semideviation: the RMS of returns falling below a minimum acceptable return.

Rolling hit rate

Fraction of strictly-positive samples in a trailing window.

Rolling information ratio

Annualised information ratio: Sharpe of active returns against a benchmark.

Rolling maximum drawdown

Worst peak-to-trough drawdown inside a trailing window.

Rolling Omega Ratio

Omega ratio over a window: total gains above a threshold divided by total losses below it.

Rolling Sharpe ratio

Annualised Sharpe ratio over a trailing window of returns.

Rolling Sortino ratio

Annualised Sortino ratio: Sharpe with downside-only deviation.

Backtesting#

Simulate a strategy against market data into a costed equity curve: signals, bars, the trade tape, and top-of-book quotes.

Function

Description

backtest_report

Running statistics and a summary for a backtest engine's output.

Backtest a two-sided market maker against L1 quotes

Backtest a two-sided market maker against a top-of-book (L1) quote stream, into a costed equity curve.

Backtest a target-position strategy against the L1 book

Backtest a target-position strategy against the L1 book, taking each quote update as a market fill to reach the target immediately.

Backtest a market maker against L1 quotes and trades

Backtest a two-sided market maker against top-of-book quotes with a trade tape driving the fills, into a costed equity curve.

Backtest a two-sided order poster on OHLC bars

Backtest a two-sided order poster on OHLC bars, posting resting bids and asks that fill when the bar's range reaches them.

Backtest a target-position strategy on OHLC bars

Backtest a target-position strategy on OHLC bars, executing market orders at the next bar's open (causal, no manual lag).

Backtest a target position on a value series

Backtest a target position against a value series (price/mark) into a costed mark-to-market equity curve.

Running report columns for a backtest

Turn a backtest engine's [equity, pnl, position, cost] into running drawdown, cost, turnover, trades, and Sharpe.

Backtest a two-sided order poster against the trade tape

Backtest a two-sided order poster against the trade tape, filling resting quotes when prints cross them, into a costed equity curve.

Backtest a target-position strategy against the trade tape

Backtest a target-position strategy against the trade tape, taking each print as a market fill to reach the target immediately.

Choosing a backtest engine

The 5x2 engine grid by data model and order definition, with fill rules and encoding.