Skip to content
Chayan Aggarwal Résumé
All case files
Case 04Personal initiativeIndependent projectPersonal project in Python

The forecast that barely beat yesterday

A regression that forecasts the next day's opening price, tested against the simplest possible rival: tomorrow equals today.

Regression0.989Naive0.97501
R² for the regression and for the naive forecast, on a full 0 to 1 axis.

The chart

  1. 01 / Symptom

    Can a simple regression on recent prices forecast tomorrow's opening price of a stock or index fund?

  2. 02 / Tests

    Built a regression in Python with pandas, scikit-learn and yfinance, then scored a "tomorrow equals today" forecast the same way.

  3. 03 / Diagnosis

    R² of 0.989 against 0.975 for the naive forecast. Prices are so autocorrelated that a high R² proves little.

  4. 04 / Prescription

    Test every forecast against the naive baseline first, and judge it on the improvement, not the headline score.

  5. 05 / Outcome

    A lesson about baselines, not a trading model.

How the tests ran

  1. Downloaded daily prices with yfinance and built lagged price features in pandas.
  2. Fitted a linear regression in scikit-learn to forecast the next day's open.
  3. Scored a naive forecast (tomorrow equals today) on the same test data.

Tools

  • Python
  • pandas
  • scikit-learn
  • yfinance

Findings

  • 0.989

    R² of the regression on price levels

  • 0.975

    R² of the naive "tomorrow equals today" forecast

Limits

  • R² on price levels flatters any forecast. Returns, or error against the naive forecast, are the fairer test.
Next case / 05One source of truth for SAP data