{"slug":"investing-at-all-time-highs","qid":"forward_returns","label":"forward_returns","post_title":"investing-at-all-time-highs","post_url":"/blog/investing-at-all-time-highs#q-forward_returns","columns":["horizon","record_closes","other_closes","record_median_pct","other_median_pct","record_positive_pct","other_positive_pct"],"rows":[{"horizon":"1 year","record_closes":427,"other_closes":4108,"record_median_pct":12.6,"other_median_pct":13.7,"record_positive_pct":78.2,"other_positive_pct":82.6},{"horizon":"3 years","record_closes":343,"other_closes":3688,"record_median_pct":26.8,"other_median_pct":38.5,"record_positive_pct":99.4,"other_positive_pct":93.6},{"horizon":"5 years","record_closes":326,"other_closes":3201,"record_median_pct":66.3,"other_median_pct":75,"record_positive_pct":99.4,"other_positive_pct":97.6}],"shape":"table","sql":"WITH\n    daily AS\n    (\n        SELECT\n            date,\n            toFloat64(argMax(close, _ingest_time)) AS close\n        FROM global_markets.stocks_daily_aggs\n        WHERE ticker = 'SPY'\n        GROUP BY date\n    ),\n    flagged AS\n    (\n        SELECT\n            date,\n            close,\n            close >= max(close) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)     AS is_record,\n            min(date) OVER ()                                                                              AS series_start,\n            leadInFrame(close, 252)  OVER (ORDER BY date ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS close_1y,\n            leadInFrame(close, 756)  OVER (ORDER BY date ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS close_3y,\n            leadInFrame(close, 1260) OVER (ORDER BY date ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS close_5y\n        FROM daily\n    ),\n    unpivoted AS\n    (\n        SELECT\n            date,\n            close,\n            is_record,\n            arrayJoin([('1 year', close_1y), ('3 years', close_3y), ('5 years', close_5y)]) AS pair,\n            tupleElement(pair, 1) AS horizon,\n            tupleElement(pair, 2) AS close_fwd\n        FROM flagged\n        WHERE date >= addYears(series_start, 4)\n    )\nSELECT\n    horizon,\n    countIf(is_record = 1)                                                                                    AS record_closes,\n    countIf(is_record = 0)                                                                                    AS other_closes,\n    round(quantileDeterministicIf(0.5)(100 * (close_fwd / close - 1), toYYYYMMDD(date), is_record = 1), 1)    AS record_median_pct,\n    round(quantileDeterministicIf(0.5)(100 * (close_fwd / close - 1), toYYYYMMDD(date), is_record = 0), 1)    AS other_median_pct,\n    round(100 * countIf(is_record = 1 AND close_fwd > close) / countIf(is_record = 1), 1)                      AS record_positive_pct,\n    round(100 * countIf(is_record = 0 AND close_fwd > close) / countIf(is_record = 0), 1)                      AS other_positive_pct\nFROM unpivoted\nWHERE close_fwd > 0\nGROUP BY horizon\nHAVING countIf(is_record = 1) > 0 AND countIf(is_record = 0) > 0\nORDER BY horizon","computed_at":"2026-09-20T15:14:15.341056+00:00","elapsed":0.151567211}