Moe Chizari

Projects

Interactive demo

Stock Predict project report

Project Overview:

The Stock Predict project in Data Science aims to forecast stock or asset prices using advanced time series models like ARIMA, Prophet, or LSTM. This tool is designed to assist investors and financial analysts predict future price movements based on historical data. The primary focus is on cleaning, analyzing, and predicting stock prices from sources such as Yahoo Finance.

Data Collection and Preparation:

I began by collecting historical stock data from Yahoo Finance, focusing on the key variable “close” stock prices. The dataset was preprocessed to ensure proper format compatibility with the models we used. This included:

  • Converting date strings into datetime objects.
  • Filtering necessary columns.
  • Handling missing values and outliers through data cleaning techniques.

Model Implementation in Stock Predict project:

Two main types of models were used for stock prediction in this project:

ARIMA Model:

  • Implemented using the pmdarima library, ARIMA was applied after checking for stationarity and seasonality in the data.
  • The ARIMA model produced reasonable predictions for stock prices over a selected time range. It is particularly suited for shorter-term predictions without significant external shocks.

LSTM Model:

  • Implemented using TensorFlow/Keras, the LSTM (Long Short-Term Memory) model was chosen to capture the complex, non-linear patterns in stock price movements.
  • Challenges arose in fitting the data due to the inherent unpredictability caused by fundamental factors (like market events), but LSTM performed well over shorter time spans.

Key Challenges in stock predict project:

  • Fundamental Effects: High-impact market events such as financial announcements and geopolitical shifts are difficult to model. I observed that currencies and stocks with such events had a higher error range in our predictions.
  • Wide Date Ranges: When using a broad time span, we encountered difficulties in capturing consistent trends, resulting in less accurate predictions.

Results for stock predict project:

  • The accuracy of predictions improved significantly when focusing on shorter time ranges. For example:
  • Figure 1 shows the performance of the LSTM model over a wide date range, where fundamental events affected prediction accuracy.
  • Figure 2 demonstrates more accurate results in a shorter period with fewer fundamental disruptions.
Line chart: a share price from 2014 to 2024 with training, validation and test predictions against observations. The test predictions stay near 360 while the observed price rises above 450.
Line chart: a share price from mid-2014 to early 2019 with training, validation and test predictions. The test predictions stay near 96 while the observations move between about 95 and 115.

Conclusion and Recommendations:

  • Shorter Timeframes: The LSTM model performs better with tighter time ranges, where fewer fundamental factors influence stock movements.
  • Broader Features: Incorporating features like the high, low, and open prices of stock (instead of only the “close”) can enhance prediction accuracy for the next candle.
  • Real-World Application: In a practical setting, using this approach on crypto assets with data granularity down to minutes could provide more dependable results.

All write-ups