Sortino Ratio
The Sortino node computes a rolling Sortino-like ratio: mean(window) / downside_std(window). Downside std is computed using only negative values: √(Σ v² for v < 0 / n) where n is the full window size. Unlike Sharpe, Sortino penalizes only downside volatility, making it appropriate when strategy returns are asymmetrically distributed. Returns null when downside std is zero.
Algorithm
- ▸μ = mean(non-null vals)
- ▸downside_std = √(Σ v² for v < 0, summed over all n non-null vals / n)
- ▸output = μ / downside_std
- ▸Returns null when downside_std = 0 (no negative values in window)
- ▸Requires ≥ 2 non-null values
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| period | number | 20 | Rolling window size. |
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Inputs | ||
| input | number[] | Source numeric array |
| Outputs | ||
| values | number | null | Computed value at each bar; null before the warmup period completes |
| timestamps | number[] | Bar timestamps (UNIX ms), aligned 1-to-1 with values |
Use Cases
Downside Risk Profiling
Sortino > Sharpe indicates that most volatility is on the upside (positive surprise) — a more favorable risk profile. Sortino << Sharpe warns of frequent small gains but occasional large losses.
Asymmetric Return Strategy Ranking
When ranking strategies with non-symmetric return distributions (e.g., options selling), Sortino provides a more appropriate risk-adjusted ranking than Sharpe.
Position Size Adjuster
Use 1 / (1 + |Sortino_deficiency|) as a multiplier to reduce position size when the rolling Sortino falls below a target threshold.