HHM on Stock Prediction

Research project on developing a Hidden Markov Model for stock price prediction.

Problem Statement

Predicting stock market trends remains a complex challenge due to its inherent volatility and the potential for substantial financial returns. In this project, we used the Hidden Markov Model (HMM) to predict stock prices by representing market dynamics through hidden states. The study's analysis concludes that the prediction results are elatively accurate, particularly in forecasting the trend of the company's stock fluctuations. However, the variance is significant, indicating a need to incorporate more ontrol variables and combine different prediction methods to achieve more accurate stock prediction results.

Results and Analysis

Dataset and Preprocessing

  • - Used historical stock data from Apple, NVIDIA, and Amazon.

  • - Preprocessed data using log return calculations and data standardization to stabilize variance.

Optimal Hidden State Selection

  • - Determined the optimal number of hidden states using AIC, BIC, HQC, CAIC to balance model complexity and accuracy.

  • - 5-6 states was found to be optimal for the selected stocks.

Sliding Window Prediction

  • - Employed sliding window approach, with HMMs trained on 96 previous observations to predict the next 96 time step.

  • - Ensured adaptability to recent market conditions.

Model Evaluation

  • - Evaluated using Mean Absolute Percentage Error (MAPE).

  • - Showed reasonable accuracy but some deviations due to market shifts.

  • - Captured general trends well but struggled with sudden changes.

Limitations

  • - Markov property assumption and stationarity may not hold true in dynamic financial market.

  • - Struggled to accurately predict rare, high-impact market events (e.g., crashes or booms) due to their reliance on Gaussian emissions and historical data.

Future Directions

  • - Combine HMMs with other techniques like Long Short-Term Memory (LSTM) networks or regime-switching models.

  • - Develop methods to dynamically adjust the number of hidden states based on evolving market conditions.

Tech Stack

PythonPython
PandasPandas
NumpyNumpy