自相关

Python 中的时间序列分析

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

什么是自相关?

  • 序列与其滞后副本的相关性
  • 也称为序列相关
  • 一阶滞后自相关
Python 中的时间序列分析

自相关的解释

  • 均值回归 —— 负自相关
Python 中的时间序列分析

自相关的解释

  • 动量趋势跟随 —— 正自相关

Python 中的时间序列分析

交易者用自相关获利

  • 个股
    • 历史上多为负自相关
    • 以短周期(天)衡量
    • 策略:买入输家,卖出赢家
  • 商品与货币
    • 历史上多为正自相关
    • 以更长周期(月)衡量
    • 策略:买入赢家,卖出输家
Python 中的时间序列分析

正自相关示例:汇率

  • 使用来自 FRED 的每日日元/美元汇率 DataFrame df
  • 将索引转换为 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
Python 中的时间序列分析

开始练习!

Python 中的时间序列分析

Preparing Video For Download...