Balaena Quant's LogoBalaena Quant
Performance

Metrics

Reference for all performance metrics computed by ADRS after a backtest.

After a backtest completes, alpha.backtest() returns a Performance object that bundles every metric in one place.

performance, df = alpha.backtest(...)

print(performance.sharpe_ratio)
print(performance.max_drawdown_percentage)
print(performance.win_rate)

Performance model

Performance is a Pydantic model, meaning all fields are validated and type-safe. It is structured into three logical groups: ratio metrics, drawdown metrics, and trade metrics.

Ratio metrics

These metrics measure risk-adjusted returns and general profitability.

FieldTypeDescription
sharpe_ratiofloatAnnualised Sharpe ratio: mean excess return divided by its standard deviation
sortino_ratiofloatLike Sharpe but only penalises downside volatility
calmar_ratiofloatCAGR divided by maximum drawdown
cagrfloatCompound annual growth rate
annualized_returnfloatAnnualised return as a decimal (e.g. 0.35 = 35 %)
total_returnfloatCumulative return over the full period
min_cumufloatMinimum cumulative equity reached at any point

Drawdown metrics

Drawdown describes the peak-to-trough decline in equity. ADRS tracks the single largest drawdown episode in detail.

FieldTypeDescription
max_drawdownfloatLargest absolute equity decline
max_drawdown_percentagefloatLargest drawdown as a percentage of peak equity
max_drawdown_start_datedatetimeWhen the drawdown episode began
max_drawdown_end_datedatetimeWhen the equity reached its trough
max_drawdown_recover_datedatetimeWhen equity recovered to the prior peak
max_drawdown_max_duration_in_daysfloatTotal drawdown episode length in days

Trade metrics

Trade metrics characterise how the strategy actually trades over the evaluation period.

FieldTypeDescription
num_tradesintTotal number of trades executed
long_tradesintNumber of long trades
short_tradesintNumber of short trades
win_tradesintNumber of winning trades
lose_tradesintNumber of losing trades
win_ratefloatWin rate as a decimal (e.g. 0.6 = 60 %)
win_streakintLongest consecutive winning streak
lose_streakintLongest consecutive losing streak
avg_holding_time_in_secondsfloatAverage trade duration in seconds
num_datapointsintTotal number of bars in the evaluation window

Period & metadata

FieldTypeDescription
start_timedatetimeEvaluation period start
end_timedatetimeEvaluation period end
metadatadict[str, Any]Arbitrary key/value pairs for custom annotations

Computing Performance from a DataFrame

If you have a backtest result DataFrame and want to (re-)compute metrics without running the full backtest again, use the class method:

from adrs.types import Performance

perf = Performance.from_df(
    df=result_df,
    start_time=start_time,
    end_time=end_time,
    metadata={"note": "manual recompute"},
)

This is useful when loading a cached result DataFrame from disk and inspecting metrics.


Metric classes (advanced)

Internally, ADRS computes metrics through three composable Metrics subclasses. You can instantiate them directly if you want to compute individual metric groups on an arbitrary DataFrame.

The df passed to each compute() method must be the backtest result DataFrame (the second element of the alpha.backtest() return value) and must contain at minimum: start_time, pnl, equity, signal, trade.

On this page