What Is the Sharpe Ratio? Formula and Math
Sharpe against Sortino, six names, calendar 2025ranking ·
2026-08-06 · 6×4
SPY annualized Sharpe ratio, year by year, fixed 4.25% assumed rateranking ·
2026-08-06 · 10×3
Annualized Sharpe ratio by name, calendar 2025, assumed 4.25% risk-free rateranking ·
2026-08-06 · 6×4
One year of SPY, three sampling frequencies, one annualized Sharpe ratioranking ·
2026-08-06 · 3×3
Same SPY 2025 returns, six assumed risk-free ratesranking ·
2026-08-06 · 6×4
Sharpe against Sortino, six names, calendar 2025
Sharpe against Sortino, six names, calendar 2025
| symbol | sharpe_ratio | sortino_ratio | down_day_pct |
|---|---|---|---|
| NVDA | 0.83 | 1.18 | 46.4 |
| QQQ | 0.73 | 1.08 | 42.8 |
| SPY | 0.68 | 1.01 | 44.4 |
| MSFT | 0.52 | 0.82 | 46.4 |
| KO | 0.51 | 0.78 | 50.8 |
| AAPL | 0.28 | 0.43 | 48.4 |
the exact SQL behind every number
WITH
daily AS
(
SELECT
ticker AS symbol,
toDate(toTimeZone(window_start, 'America/New_York')) AS session_date,
argMax(toFloat64(close), window_start) AS close_px
FROM global_markets.delayed_stocks_minute_aggs
WHERE ticker IN ('SPY', 'QQQ', 'AAPL', 'MSFT', 'NVDA', 'KO')
AND window_start >= toDateTime('2024-12-24 00:00:00')
AND window_start < toDateTime('2026-01-01 05:00:00')
AND (toHour(toTimeZone(window_start, 'America/New_York')) * 60
+ toMinute(toTimeZone(window_start, 'America/New_York'))) >= 570
AND (toHour(toTimeZone(window_start, 'America/New_York')) * 60
+ toMinute(toTimeZone(window_start, 'America/New_York'))) < 960
GROUP BY symbol, session_date
),
stepped AS
(
SELECT
symbol,
session_date,
close_px,
lagInFrame(close_px, 1) OVER (PARTITION BY symbol ORDER BY session_date
ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS prev_px
FROM daily
),
excess AS
(
SELECT
symbol,
close_px / prev_px - 1 - 0.0425 / 252 AS ex_ret
FROM stepped
WHERE prev_px > 0
AND session_date >= toDate('2025-01-01')
)
SELECT
symbol,
round(avg(ex_ret) / stddevSamp(ex_ret) * sqrt(252), 2) AS sharpe_ratio,
round(avg(ex_ret) / sqrt(avg(pow(least(ex_ret, 0.0), 2))) * sqrt(252), 2) AS sortino_ratio,
round(countIf(ex_ret < 0) * 100.0 / count(), 1) AS down_day_pct
FROM excess
GROUP BY symbol
HAVING count() > 200 AND countIf(ex_ret < 0) > 0
ORDER BY sortino_ratio DESC
More from this analysisWhat Is the Sharpe Ratio? Formula and Math
SPY annualized Sharpe ratio, year by year, fixed 4.25% assumed rate
ranking 10×3
→
Annualized Sharpe ratio by name, calendar 2025, assumed 4.25% risk-free rate
ranking 6×4
→
Same SPY 2025 returns, six assumed risk-free rates
ranking 6×4
→
One year of SPY, three sampling frequencies, one annualized Sharpe ratio
ranking 3×3
→
See all 2,173 queries →