Giter VIP home page Giter VIP logo

hmm-stock-forecast's Introduction

HMM-Stock-Forecast

Stock forecasting based on (gaussian) Hidden Markov Model

Model

Model implementation is based on these two articles:

  • [1] Nguyen N. Hidden Markov Model for Stock Trading. International Journal of Financial Studies. 2018; https://doi.org/10.3390/ijfs6020036.
  • [2] M. R. Hassan and B. Nath, Stock market forecasting using hidden Markov model: a new approach 5th International Conference on Intelligent Systems Design and Applications (ISDA’05), 2005, pp. 192-196, doi: 10.1109/ISDA.2005.85.

Arguments

Application accept these arguments:

  • -t stock ticker (e.g. AAPL)
  • -f path to csv soubor (4 columns: Open, Low, High, Close)
  • -s data start date
  • -e data end date
  • -w window size (see [1] for more information about window)
  • -m type of hmm implementation:

Run

  • In first step program find number of optimal hidden states (n) based on:

    • AIC (Akaike information criterion)
    • BIC (Bayesian information criterion)
    • HQC (Hannan-Quinn information criterion)
    • CAIC (Bozdogan Consisten Akaike information criterion)
  • Then prediction is estimated for w (window) business days. Everytime historical data 0-x are used to predict closing price at day x+1

Run

Results

  • Ticker: SPY

  • Start date: 2019-01-01

  • End date: 2022-01-01

  • Window size: 100

  • MAPE: 0.861 %

  • r2: 82 %

Result

Dependencies

  • numpy
  • matplotlib
  • pandas
  • sklearn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.