Belle Shen

Welcome to my website! 🚀🪐⭐

Belle Shen

Belle Shen

Welcome to my website! 🚀🪐⭐

Facebook/Meta Stock Price Forecasting

Facebook/Meta Stock Price Forecasting

Project Goal
The goal of this project was to build an ARIMA (autoregressive integrated moving average) model to forecast by using the stock open price of FB on Aug. 31, 2021 and the model was trained by using the price from Aug 1 to 30, 2021.

Library
We used Pandas for data analysis, matplotlib for visualization, NumPy & scikit-learn for model evaluation, and statsmodels for the ARIMA algorithm and Augmented Dickey-Fuller test.

ARIMA Model Requirements
In this ARIMA model, the order of (P, D, Q) values should be decided and P represents autoregressive terms, D is the number of difference levels in order to get stationary data and Q stands for moving-average terms.

For selecting these values, plotting partial autocorrelation function (pacf) & autocorrelation function (acf) can get the reference values of P and Q respectively by taking the cut-off point.

By performing Augmented Dickey-Fuller test to obtain p-value, we can obtain what would be a good value of D with p-value < 0.05 which means the data was stationary.

Data Analysis Result
By plotting pacf and acf, the value of “2” might be a good value for P, but we really could not see what a good value for Q might be.

And one difference level of the data would allow us to get a p-value smaller than 0.05 by running the Augmented Dickey-Fuller test.

Hyperparameters Tuning
Overall, those P, D, Q values we had from the above data analysis results only act as a reference. We still needed to get the optimized P, D, Q values from doing hyperparameter tuning, and to see which permutations of P, D, Q yields the smallest RMSE (Root Mean Square Error).

p.s.: Because this was similar to a regression problem, thus RMSE would be a better metric to evaluate the model.

Results
From the hyperparameter tuning results, the best permutation of P, D, Q was obtained, so we would use this order to train the whole dataset getting the final ARIMA model for forecasting the next day stock price.
Resulting in an RMSE = $0.88 for the price on Aug. 31.

For detail codes and graphs, please check the GitHub link above 👆

Want to get the next minute forecast? download my notebook here and run it by yourself!

Real-Time Forecasting

If you want to forecast other companies stock market price in real time, try my notebook here.

And I have an article which explains how my codes work, you can check my post.

photo credit: https://www.financialexpress.com/investing-abroad/featured-stories/us-stock-futures-fall-as-big-week-of-earnings-reports-kicks-off/2495305/