Skip to content

TJ-HOU/CUSUM_Trading_Strategy

Repository files navigation

CUSUM Trading Strategy

Objective

  • Use CUSUM techniques to trade securities

Data

  • SPY,SPYV,SPYG,HSI daily adj. close from Yahoo Finance

Walk through the code

Part 1: EDA

  • Step1: Download SPY,SPYV,SPYG,HSI daily adj. close
  • Step2: Plot time series, cumulative, and kde of log-return

image

image

  • Step3: Calculate basic statistics of log-return

image

Part 2: Implement CUSUM strategy on SPY vs HSI, SPYV vs SPYG

  • Step1: Set length of the rolling window, trading period, cusum threshold
  • Step2: Get the today's data and the last window-length data
  • Step3: Calibrate parameters of the distribution functions
  • Step4: Calculate cusum statistics
  • Step5: Determine positions based on cusum statistics relative to the threshold
  • Step6: Calculate the cumulative return
  • Step7: Plot cusum statistics and cumulative return marked with trading signals

image

image

  • Step8: Compare results of SPY vs HSI

image

  • Step9: Compare results of SPYG vs SPYV

image

Output

About

Use CUSUM techniques to trade SPY,SPYG,SPYV,HSI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published