Autocorrelation

Time Series Analysis in Python

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

What is Autocorrelation?

  • Correlation of a time series with a lagged copy of itself
  • Also called serial correlation
  • Lag-one autocorrelation
Time Series Analysis in Python

Interpretation of Autocorrelation

  • Mean Reversion - Negative autocorrelation
Time Series Analysis in Python

Interpretation of Autocorrelation

  • Momentum, or Trend Following - Positive autocorrelation

Time Series Analysis in Python

Traders Use Autocorrelation to Make Money

  • Individual stocks
    • Historically have negative autocorrelation
    • Measured over short horizons (days)
    • Trading strategy: Buy losers and sell winners
  • Commodities and currencies
    • Historically have positive autocorrelation
    • Measured over longer horizons (months)
    • Trading strategy: Buy winners and sell losers
Time Series Analysis in Python

Example of Positive Autocorrelation: Exchange Rates

  • Use daily $\yen$/$ exchange rates in DataFrame df from FRED
  • Convert index to datetime
# Convert index to datetime
df.index = pd.to_datetime(df.index)

# Downsample from daily to monthly data df = df.resample(rule='M').last()
# Compute returns from prices df['Return'] = df['Price'].pct_change()
# Compute autocorrelation autocorrelation = df['Return'].autocorr() print("The autocorrelation is: ",autocorrelation)
The autocorrelation is: 0.0567
Time Series Analysis in Python

Let's practice!

Time Series Analysis in Python

Preparing Video For Download...