Predicting Stocks : Not a trivial matter!
Why is it so hard to predict stocks? As a little exercise, I decided to put to test my humble (and quite amateur) knowledge on Time Series Analysis and attempted to build a prediction model for stocks closing prices of a certain company, based on three months of historical data. What were the results?
Fitting the trend
Fitting an ARIMA model
Forecasting the future
For this exercise, I originally had 42 data points (that is, weekdays data for 3 months, I leave the math to you), from which I used 32 for training and 10 for testing. The results after adjusting the trend are shown by the graph above; the squiggly lines represent the original data points, while the almost straight line at the end represents the predictions from the model. They look pretty close to the real ones eh? Here's the catch: notice the blue area and the bigger area around it; these are 80% and 95% confidence bounds respectively. This is saying: 80% and 95% of the time, respectively, the real value, as opposed to our predictions, will fall inside that interval. In this case, these are huge!!! In particular, the farther we predict into the future, the wider they become. Notice, for instance, the one for May 01: the lowest value of the 95% lower bound is roughly 34$, while the biggest one is 15$. In a real-world situation, this prediction is absolutely flawed and disastrous; this is as good as guessing by eye what tomorrow's value will be! (or even worse). The truth is, even domain professionals often have a hard time doing these kinds of predictions. This shows just how hard it is to predict the stock market.