自己相関

Pythonで学ぶ時系列解析

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

自己相関とは?

  • 時系列とそのラグ付きコピーとの相関
  • 系列相関とも呼ばれる
  • ラグ1の自己相関
Pythonで学ぶ時系列解析

自己相関の解釈

  • 平均回帰 - 負の自己相関
Pythonで学ぶ時系列解析

自己相関の解釈

  • モメンタムトレンドフォロー) - 正の自己相関

Pythonで学ぶ時系列解析

トレーダーが自己相関を活用する方法

  • 個別株
    • 歴史的に負の自己相関を持つ
    • 短期(日次)で計測
    • 戦略:負け銘柄を買い、勝ち銘柄を売る
  • コモディティ・通貨
    • 歴史的に正の自己相関を持つ
    • 長期(月次)で計測
    • 戦略:勝ち銘柄を買い、負け銘柄を売る
Pythonで学ぶ時系列解析

正の自己相関の例:為替レート

  • FRED から取得した DataFrame df の日次 $\yen$/$ 為替レートを使用
  • インデックスを 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...