Autocorrelation Properties of SP500-Quantitative Trading in Python

Subscribe to newsletter

A technical or quantitative trading system on a linear (i.e. delta 1) instrument is basically a bet on the autocorrelation of the underlying. The autocorrelation properties of the underlying can be examined directly through autocorrelation functions or indirectly through the Hurst exponent.

In this post, we are going to examine the mean-reverting and trending properties of SP500 directly using the autocorrelation functions. We do so with the goal of designing quantitative trading systems on stock indices.

Recall that,

Subscribe to newsletter https://harbourfrontquant.beehiiv.com/subscribe Newsletter Covering Trading Strategies, Risk Management, Financial Derivatives, Career Perspectives, and More

Autocorrelation, also known as serial correlation, is the correlation of a signal with a delayed copy of itself as a function of delay. Informally, it is the similarity between observations as a function of the time lag between them. The analysis of autocorrelation is a mathematical tool for finding repeating patterns, such as the presence of a periodic signal obscured by noise, or identifying the missing fundamental frequency in a signal implied by its harmonic frequencies. It is often used in signal processing for analyzing functions or series of values, such as time domain signals. Read more

We implemented the autocorrelation functions in Python. We downloaded SPY data from 2009 to the present from Yahoo Finance. We then applied the Python program to the daily and monthly returns of SPY.

The graph below shows the autocorrelation (ACF) and partial autocorrelation (PACF) functions of daily SPY returns. We note that SPY returns are negatively correlated at lags 2-4, i.e. SPY is mean-reverting in the short term. This is consistent with the findings in the previous study performed using the Hurst exponent.

Quantitative Trading in Python

The graph below shows the autocorrelation and partial autocorrelation functions of monthly SPY returns. We observe that the monthly returns are positively correlated around lag 9. This means that in a long term, SPY is trending.

Quantitative Trading in Python

In summary, using the autocorrelation functions, we demonstrated that the SP500 is mean-reverting in the short term and trending in the long term. In the next installments, we will design trading systems based on the mean-reverting and trending properties of SPY.


To download the accompanying Excel workbook or Python program for this post:
1. Subscribe to the newsletter. If you're already a subscriber, go to the next step
2. Once subscribed, refer a friend
After completing these steps, you’ll gain access to the file for this post, along with files for a dozen other posts.

Further questions

What's your question? Ask it in the discussion forum

Have an answer to the questions below? Post it here or in the forum

LATEST NEWSUK leads G7 countries in addressing child sexual violence, but ODA cuts are hurting progress
UK leads G7 countries in addressing child sexual violence, but ODA cuts are hurting progress

The Brave Movement, a special initiative of Together for Girls, unveils the #BeBrave G7 Scorecard – an assessment of five indicators which illuminate how the world’s richest nations are addressing the global crisis of childhood sexual violence LONDON, June 12, 2025 (GLOBE NEWSWIRE) — The…

Stay up-to-date with the latest news - click here
LATEST NEWSMarines to deploy on LA streets within two days with authority to detain civilians
Marines to deploy on LA streets within two days with authority to detain civilians
Stay up-to-date with the latest news - click here
LATEST NEWSAustralian accused of mushroom murders denies poisoning lunch as cross-examination ends
Australian accused of mushroom murders denies poisoning lunch as cross-examination ends
Stay up-to-date with the latest news - click here
LATEST NEWSKenya's budget to weigh revenue growth against public outrage
Kenya's budget to weigh revenue growth against public outrage
Stay up-to-date with the latest news - click here
LATEST NEWSAirbus revises up 20-year jet demand forecast despite trade tensions
Airbus revises up 20-year jet demand forecast despite trade tensions
Stay up-to-date with the latest news - click here

2 Comments

Leave a Reply