Skip to content

About

Modify MAs-Crossover-Strategies by Hidden Markov model

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

26 Commits

Folders and files

Repository files navigation

Hidden Markov Model Enhanced SMA Strategies

Overview: Utilizing Hidden Markov Models (HMM) to identify different regimes, this repository features three distinct SMA-based trading strategies on SPY. The strategies are activated during these identified bull regimes to optimize performance.

Note: For correct rendering, please clone this repository and open the .ipynb notebook locally in Jupyter or VS Code.

Strategy 1: Standard SMA Crossover

  • Long Position: Initiate when the fast SMA exceeds the slow SMA in a bull regime.
  • Close Position: Exit when the slow SMA crosses below the fast SMA or if a bear regime begins.
  • Reference: Market Regime Detection with HMM

Strategy 2: Enhanced 4-SMA Crossover

Strategy 3: Kalman Filter-SMA Integration

  • Long Position: Initiate when the Kalman filter of the close price surpasses the SMA during a bull regime.
  • Close Position: Exit when the SMA crosses below the Kalman Filter or upon a shift to a bear regime.

Setup

No Commission (e.g., Alpaca Broker)

Leverage: 3x

Parameter Grid Search: 2013-2017

For detailed backtest visualization, open the provided Notebook on Google Colab.

Result

image

  • Sharpe Ratio Sharpe Ratio of Benchmark(SPY) : 0.622

Sharpe Ratio of Strategy 1 : 0.670

Sharpe Ratio of Strategy 2 : 0.930

Sharpe Ratio of Strategy 3 : 0.657

  • Maximum Drawdown MDD of Benchmark(SPY) : 0.341

MDD of Strategy 1 : 0.324

MDD of Strategy 2 : 0.248

MDD of Strategy 3 : 0.326

Next Steps

  • Paper Trading and Live Trading

About

Modify MAs-Crossover-Strategies by Hidden Markov model

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages