Performance metrics (fynance.metrics)¶
Risk-adjusted ratios, return and drawdown metrics to evaluate a strategy
out-of-sample. A metric evaluates a series — distinct from
fynance.features, which builds inputs.
Ratios & returns¶
|
Compute the Sharpe ratio for each X' series. |
|
Compute the Sortino ratio for each X' series. |
|
Compute the Calmar Ratio for each X' series. |
|
Compute compounded annual returns of each X' series. |
|
Compute the annualized volatility of each X' series. |
|
Compute diversification ratio of a portfolio. |
|
Compute performance of prices or index values along time axis. |
|
Compute performance of returns along time axis. |
|
Compute the performance of strategies for each X' series. |
|
Compute the returns of strategies for each X' series. |
Drawdown¶
|
Measures the drawdown of each X' series. |
|
Compute the maximum drawdown for each X' series. |
Tail risk¶
Value-at-Risk, Conditional Value-at-Risk (Expected Shortfall) and Conditional
Drawdown-at-Risk. Like the ratios above, var/cvar/cdar take a
price/equity curve (returns are derived internally); tail_dependence is the
exception — it takes a (T, N) returns panel directly, mirroring
information_coefficient’s pair convention.
|
Value-at-Risk of a price/equity curve's per-period returns. |
|
Conditional Value-at-Risk (Expected Shortfall) of a price/equity curve. |
|
Conditional Drawdown-at-Risk of a price/equity curve. |
|
Pairwise lower-tail dependence of a |
Rolling versions¶
|
Compute rolling sharpe ratio of each X' series. |
|
Compute the rolling Calmar ratio of each X' series. |
|
Compute rolling compounded annual returns of each X' series. |
|
Compute the annualized volatility of each X' series. |
|
Measures the rolling drawdown of each X' series. |
|
Compute the rolling maximum drawdown for each X' series. |
|
Rolling Value-at-Risk of a price/equity curve over a trailing window. |
|
Rolling Conditional Value-at-Risk of a price/equity curve. |
Benchmark-relative¶
Score a strategy against a benchmark rather than in isolation: beta and
Jensen’s alpha decompose the strategy’s return into a benchmark-driven part
and a residual, while tracking error, the information ratio and the up/down
capture ratios describe the active (strategy-minus-benchmark) return. Every
function takes two aligned price/level curves (X, B) (see
fynance.metrics.benchmark).
|
OLS slope of the strategy's returns on the benchmark's returns. |
|
Annualized Jensen's alpha of the strategy against the benchmark. |
|
Annualized standard deviation of the active (strategy - benchmark) return. |
|
Annualized mean active return over the tracking error. |
|
Up- or down-market capture ratio of the strategy against the benchmark. |
|
Standard benchmark-relative performance summary. |
|
Trailing rolling beta of the strategy against the benchmark. |
Factor analysis¶
Alphalens-style evaluation of a cross-sectional factor on a data-agnostic
(T, N) panel. The alignment convention matches
information_coefficient — factor[t] is paired with the return
realized after the factor is known.
|
Information Coefficient between a prediction and a realized outcome. |
|
Equal-count quantile-portfolio returns of a factor. |
|
Trailing-window Information Coefficient. |
|
Information Coefficient decay across forward horizons. |
|
Summary statistics of the per-bar cross-sectional Information Coefficient. |
|
Cross-sectional rank autocorrelation of a factor (turnover proxy). |
|
Per-bar quantile-portfolio returns of a factor. |
Trading exposure & turnover¶
Position-level analytics — how a book trades (churn) and sits (leverage,
long/short bias) — taking a weight/position series rather than an equity
curve, so (like the factor helpers above) these are intentionally kept out
of the METRICS registry.
|
One-way turnover per bar, \(\sum_i |w_{t,i} - w_{t-1,i}|\). |
|
Annualized one-way turnover, |
|
Gross exposure per bar, \(\sum_i |w_{t,i}|\) (total book leverage). |
|
Net exposure per bar, \(\sum_i w_{t,i}\) (long/short bias). |
|
One-shot summary of a book's turnover and exposure. |
Trade analytics¶
Round-trip trade extraction from a position book – distinct from the
churn/turnover metrics above (sign_changes, trades_per_year):
these describe individual trades (entry/exit, side, realized return) rather
than how often the position flips. See also
trades and
trade_summary.
|
Extract round-trip trades from a position series. |
|
Summary statistics of a set of round-trip trades. |
Aggregated report¶
|
Standard performance summary of an equity/price curve. |
summary is driven by the METRICS registry — a name → callable
mapping (annual_return, annual_volatility, sharpe, sortino,
calmar, max_drawdown, var, cvar, cdar) you can read or
extend.
- METRICS¶