自我相關

Python 中的時間序列分析

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

什麼是自我相關?

  • 時間序列與自身滯後版本的相關性
  • 亦稱為 序列相關
  • 一階自我相關
Python 中的時間序列分析

自我相關的解讀

  • 均值回歸:負向自我相關
Python 中的時間序列分析

自我相關的解讀

  • 動能趨勢追蹤:正向自我相關

Python 中的時間序列分析

交易員用自我相關來獲利

  • 個股
    • 歷史上多為負向自我相關
    • 多以短期區間(天)衡量
    • 交易策略:買入落後、賣出領先
  • 原物料與匯率
    • 歷史上多為正向自我相關
    • 多以較長期區間(月)衡量
    • 交易策略:買入領先、賣出落後
Python 中的時間序列分析

正向自我相關範例:匯率

  • 使用來自 FRED 的日別 $\yen$/$ 匯率,存於 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...