DocsMathStatisticsSortino Ratio

Sortino Ratio

Windowed · default period 20Statistics

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

NameTypeDefaultDescription
periodnumber20Rolling window size.

Inputs & Outputs

PortTypeDescription
Inputs
inputnumber[]Source numeric array
Outputs
valuesnumber | nullComputed value at each bar; null before the warmup period completes
timestampsnumber[]Bar timestamps (UNIX ms), aligned 1-to-1 with values
Live mode: In live streaming mode the node updates only the last bar in-place rather than recalculating the full array, keeping CPU usage minimal during real-time data feeds.

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.