{"slug":"risk-free-rate-in-the-sharpe-ratio","qid":"monthly_worked","label":"Monthly return, monthly risk-free rate and the excess, 2020 to 2024","post_title":"Risk-free rate in the Sharpe ratio","post_url":"/blog/risk-free-rate-in-the-sharpe-ratio#q-monthly_worked","columns":["month","spy_ret_pct","rf_pct","excess_pct"],"rows":[{"month":"2020-01-01","spy_ret_pct":-0.04,"rf_pct":0.128,"excess_pct":-0.17},{"month":"2020-02-01","spy_ret_pct":-7.92,"rf_pct":0.128,"excess_pct":-8.04},{"month":"2020-03-01","spy_ret_pct":-13,"rf_pct":0.025,"excess_pct":-13.02},{"month":"2020-04-01","spy_ret_pct":12.7,"rf_pct":0.012,"excess_pct":12.69},{"month":"2020-05-01","spy_ret_pct":4.76,"rf_pct":0.011,"excess_pct":4.75},{"month":"2020-06-01","spy_ret_pct":1.33,"rf_pct":0.013,"excess_pct":1.31},{"month":"2020-07-01","spy_ret_pct":5.89,"rf_pct":0.011,"excess_pct":5.88},{"month":"2020-08-01","spy_ret_pct":6.98,"rf_pct":0.009,"excess_pct":6.97},{"month":"2020-09-01","spy_ret_pct":-4.13,"rf_pct":0.009,"excess_pct":-4.14},{"month":"2020-10-01","spy_ret_pct":-2.49,"rf_pct":0.008,"excess_pct":-2.5},{"month":"2020-11-01","spy_ret_pct":10.88,"rf_pct":0.008,"excess_pct":10.87},{"month":"2020-12-01","spy_ret_pct":3.26,"rf_pct":0.007,"excess_pct":3.26},{"month":"2021-01-01","spy_ret_pct":-1.02,"rf_pct":0.007,"excess_pct":-1.03},{"month":"2021-02-01","spy_ret_pct":2.78,"rf_pct":0.004,"excess_pct":2.78},{"month":"2021-03-01","spy_ret_pct":4.2,"rf_pct":0.003,"excess_pct":4.2},{"month":"2021-04-01","spy_ret_pct":5.29,"rf_pct":0.002,"excess_pct":5.29},{"month":"2021-05-01","spy_ret_pct":0.66,"rf_pct":0.001,"excess_pct":0.66},{"month":"2021-06-01","spy_ret_pct":1.91,"rf_pct":0.003,"excess_pct":1.91},{"month":"2021-07-01","spy_ret_pct":2.44,"rf_pct":0.004,"excess_pct":2.44},{"month":"2021-08-01","spy_ret_pct":2.98,"rf_pct":0.005,"excess_pct":2.97},{"month":"2021-09-01","spy_ret_pct":-4.97,"rf_pct":0.003,"excess_pct":-4.97},{"month":"2021-10-01","spy_ret_pct":7.02,"rf_pct":0.004,"excess_pct":7.01},{"month":"2021-11-01","spy_ret_pct":-0.8,"rf_pct":0.004,"excess_pct":-0.81},{"month":"2021-12-01","spy_ret_pct":4.26,"rf_pct":0.005,"excess_pct":4.25},{"month":"2022-01-01","spy_ret_pct":-5.27,"rf_pct":0.012,"excess_pct":-5.29},{"month":"2022-02-01","spy_ret_pct":-2.95,"rf_pct":0.026,"excess_pct":-2.98},{"month":"2022-03-01","spy_ret_pct":3.44,"rf_pct":0.037,"excess_pct":3.4},{"month":"2022-04-01","spy_ret_pct":-8.78,"rf_pct":0.063,"excess_pct":-8.84},{"month":"2022-05-01","spy_ret_pct":0.23,"rf_pct":0.082,"excess_pct":0.14},{"month":"2022-06-01","spy_ret_pct":-8.64,"rf_pct":0.127,"excess_pct":-8.77},{"month":"2022-07-01","spy_ret_pct":9.21,"rf_pct":0.19,"excess_pct":9.02},{"month":"2022-08-01","spy_ret_pct":-4.08,"rf_pct":0.224,"excess_pct":-4.3},{"month":"2022-09-01","spy_ret_pct":-9.62,"rf_pct":0.265,"excess_pct":-9.88},{"month":"2022-10-01","spy_ret_pct":8.13,"rf_pct":0.317,"excess_pct":7.81},{"month":"2022-11-01","spy_ret_pct":5.56,"rf_pct":0.353,"excess_pct":5.21},{"month":"2022-12-01","spy_ret_pct":-6.19,"rf_pct":0.356,"excess_pct":-6.55},{"month":"2023-01-01","spy_ret_pct":6.29,"rf_pct":0.382,"excess_pct":5.91},{"month":"2023-02-01","spy_ret_pct":-2.51,"rf_pct":0.39,"excess_pct":-2.9},{"month":"2023-03-01","spy_ret_pct":3.31,"rf_pct":0.396,"excess_pct":2.92},{"month":"2023-04-01","spy_ret_pct":1.6,"rf_pct":0.413,"excess_pct":1.18},{"month":"2023-05-01","spy_ret_pct":0.46,"rf_pct":0.432,"excess_pct":0.03},{"month":"2023-06-01","spy_ret_pct":6.09,"rf_pct":0.44,"excess_pct":5.65},{"month":"2023-07-01","spy_ret_pct":3.27,"rf_pct":0.446,"excess_pct":2.83},{"month":"2023-08-01","spy_ret_pct":-1.63,"rf_pct":0.452,"excess_pct":-2.08},{"month":"2023-09-01","spy_ret_pct":-5.08,"rf_pct":0.452,"excess_pct":-5.53},{"month":"2023-10-01","spy_ret_pct":-2.17,"rf_pct":0.455,"excess_pct":-2.63},{"month":"2023-11-01","spy_ret_pct":9.13,"rf_pct":0.449,"excess_pct":8.69},{"month":"2023-12-01","spy_ret_pct":4.14,"rf_pct":0.443,"excess_pct":3.7},{"month":"2024-01-01","spy_ret_pct":1.59,"rf_pct":0.444,"excess_pct":1.15},{"month":"2024-02-01","spy_ret_pct":5.22,"rf_pct":0.442,"excess_pct":4.78},{"month":"2024-03-01","spy_ret_pct":2.95,"rf_pct":0.445,"excess_pct":2.51},{"month":"2024-04-01","spy_ret_pct":-4.03,"rf_pct":0.443,"excess_pct":-4.47},{"month":"2024-05-01","spy_ret_pct":5.06,"rf_pct":0.444,"excess_pct":4.61},{"month":"2024-06-01","spy_ret_pct":3.2,"rf_pct":0.448,"excess_pct":2.75},{"month":"2024-07-01","spy_ret_pct":1.21,"rf_pct":0.442,"excess_pct":0.77},{"month":"2024-08-01","spy_ret_pct":2.34,"rf_pct":0.431,"excess_pct":1.91},{"month":"2024-09-01","spy_ret_pct":1.79,"rf_pct":0.401,"excess_pct":1.39},{"month":"2024-10-01","spy_ret_pct":-0.89,"rf_pct":0.385,"excess_pct":-1.28},{"month":"2024-11-01","spy_ret_pct":5.96,"rf_pct":0.377,"excess_pct":5.59},{"month":"2024-12-01","spy_ret_pct":-2.73,"rf_pct":0.359,"excess_pct":-3.09}],"shape":"series","sql":"WITH\n    monthly_px AS\n    (\n        SELECT\n            toStartOfMonth(date)           AS m,\n            argMax(toFloat64(close), date) AS month_close\n        FROM global_markets.stocks_daily_aggs\n        WHERE ticker = 'SPY'\n          AND date >= '2019-12-01'\n          AND date <  '2025-01-01'\n        GROUP BY m\n    ),\n    prior_px AS\n    (\n        SELECT\n            addMonths(m, 1) AS m,\n            month_close     AS prev_close\n        FROM monthly_px\n    ),\n    monthly_rf AS\n    (\n        SELECT\n            toStartOfMonth(date)                                       AS m,\n            pow(1 + avg(toFloat64(yield_3_month)) / 100, 1.0 / 12) - 1 AS rf_month\n        FROM global_markets.treasury_yields\n        WHERE date >= '2019-12-01'\n          AND date <  '2025-01-01'\n          AND yield_3_month IS NOT NULL\n        GROUP BY m\n    )\nSELECT\n    toString(cur.m)                                                      AS month,\n    round(100 * (cur.month_close / prv.prev_close - 1), 2)               AS spy_ret_pct,\n    round(100 * rf.rf_month, 3)                                          AS rf_pct,\n    round(100 * (cur.month_close / prv.prev_close - 1 - rf.rf_month), 2) AS excess_pct\nFROM monthly_px AS cur\nINNER JOIN prior_px AS prv ON prv.m = cur.m\nINNER JOIN monthly_rf AS rf ON rf.m = cur.m\nORDER BY cur.m","computed_at":"2026-08-14T15:41:54.541221+00:00","elapsed":0.003204662}