Skip to content

shortthirdman/Market-Regime-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Market-Regime-Detection

Market Regime Detection using Hidden Markov Models

  • Hidden Markov Models (HMMs): HMMs are statistical models assuming a system transitions through a sequence of unobservable (“hidden”) states. Each state has a probability distribution governing the observable outputs (or features). In finance, we can think of market regimes (bull, bear, ranging) as hidden states, and price movements (like returns and volatility) as observable features.

  • Backtrader: A popular Python framework for backtesting trading strategies and creating financial visualizations. It handles data loading, indicator calculations, strategy logic, and plotting.

  • Market Regimes: Distinct periods in the market characterized by different price behavior (e.g., strong upward trend, sharp downward trend, low-volatility sideways movement). Identifying the current regime can be crucial for adjusting trading strategies.

Made withJupyter GitHub License GitHub code size in bytes GitHub repo size Static Badge


Local Development

  • Create a Python virtual environment and activate

    $ python -m venv --upgrade-deps --clear dev
    $ export PIP_CONFIG_FILE=".\pip.conf"
    # PowerShell
    $ .\dev\Scripts\Activate.ps1
    # Linux/macOS
    $ source dev/bin/activate
    # Windows Command Prompt
    $ .\dev\Scripts\activate.bat
  • Install the packages and dependencies as listed in requirements file

    $ pip install -U -r requirements.txt --no-cache-dir --disable-pip-version-check
  • Start your development Jupyter Notebook or Jupyter Lab server

    $ jupyter lab --notebook-dir=.\notebooks --no-browser
  • Install the below packages to run the Python script

    $ pip install -q backtrader yfinance numpy pandas hmmlearn matplotlib

About

Market Regime Detection using Hidden Markov Models

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published