Sharpe Ratio
The Sharpe node computes a rolling Sharpe-like ratio assuming zero risk-free rate: mean(window) / population_std(window). When the input is a series of returns, this is the classical per-period Sharpe ratio. Higher values indicate better risk-adjusted return; negative values mean the average return is negative relative to its volatility. Requires at least 2 non-null values.
Algorithm
- ▸vals = non-null values in window
- ▸μ = mean(vals), σ = population_std(vals)
- ▸output = μ / σ
- ▸Returns null when σ = 0 (zero-variance window)
- ▸Note: uses population std, not sample std — differs from annualized broker Sharpe metrics
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
Rolling Risk Quality
Monitor rolling Sharpe on a strategy's bar-by-bar P&L series to detect when risk-adjusted performance degrades — a Sharpe drop below 0.5 may trigger a strategy pause.
Asset Ranking
Rank tradable instruments by their rolling Sharpe on returns to select the current best risk-adjusted performers for a rotating long-only portfolio.
Regime Quality Gate
Enter new positions only when rolling Sharpe on recent returns is positive — ensuring you are entering during periods of historically positive risk-adjusted momentum.