Autocorrelation

การวิเคราะห์อนุกรมเวลาด้วย Python

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

Autocorrelation คืออะไร?

  • ความสัมพันธ์ของอนุกรมเวลากับค่าที่ล้าหลัง (lagged copy) ของตัวเอง
  • เรียกอีกชื่อว่า serial correlation
  • Lag-one autocorrelation
การวิเคราะห์อนุกรมเวลาด้วย Python

การตีความ Autocorrelation

  • Mean Reversion - Autocorrelation เชิงลบ
การวิเคราะห์อนุกรมเวลาด้วย Python

การตีความ Autocorrelation

  • Momentum หรือ Trend Following - Autocorrelation เชิงบวก

การวิเคราะห์อนุกรมเวลาด้วย Python

เทรดเดอร์ใช้ Autocorrelation เพื่อทำกำไร

  • หุ้นรายตัว
    • มี autocorrelation เชิงลบในอดีต
    • วัดในช่วงเวลาสั้น (รายวัน)
    • กลยุทธ์: ซื้อหุ้นที่แพ้ ขายหุ้นที่ชนะ
  • สินค้าโภคภัณฑ์และสกุลเงิน
    • มี autocorrelation เชิงบวกในอดีต
    • วัดในช่วงเวลายาว (รายเดือน)
    • กลยุทธ์: ซื้อหุ้นที่ชนะ ขายหุ้นที่แพ้
การวิเคราะห์อนุกรมเวลาด้วย Python

ตัวอย่าง Autocorrelation เชิงบวก: อัตราแลกเปลี่ยน

  • ใช้อัตราแลกเปลี่ยน $\yen$/$ รายวันใน DataFrame df จาก FRED
  • แปลง index เป็น 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...