Week 4 - Never back down never what?
March 22, 2024
Never give up. Hello everybody and welcome back to Week 4 of my Senior Project! This week, I spent a lot of time focusing on trying to make my ARIMA model work after the error messages displayed last week.
For reference, here are the error messages that I encountered last time:
My model had multiple errors in the code. First, this model was based off of one that was used to predict the value of cryptocurrency, which updates every day. However, the stock market is very different. The stock market is closed on weekends and holidays, which is something that I didn’t take into consideration when making the dataset. Therefore, when making predictions, I asked the model to use a daily increment, but it returned error messages when it reached Fridays, as my dataset went straight to Monday from Friday (and skipped Saturday and Sunday). Additionally, I had no idea which format the model was storing predictions in (whether as fractions, decimals, or scientific notation), so that could have also been one reason why it was returning the error message of “Not a Number.” To fix both of these problems, I created a Python program called “dataset modifier” that parsed through my dataset, identified any missing days, and filled it with the last active stock price. For example, if the opening price of a stock on Friday was $101.11 and the opening price on Monday was $105.21, the program would automatically fill in the stock price for Saturday and Sunday to be $101.11. It then created a new dataset of two columns – one with the date (with no missing values this time) and one with the stock price truncated to two decimals so I could control the format of the stock prices. After doing this, I had 8 new datasets with no missing values and stock prices with only two decimal values. Finally, I had a logical error in my program where it was forecasting values on a weekly basis, however this was an easy fix as I just changed the code to forecast stock values on a daily basis like I wanted.
After making those changes to my data and program, I ran the model. It returned its forecasts for my 8 companies (Amazon, Apple, Google, Meta, Microsoft, Nvidia, Sharps Technologies, Tesla). The results are shown below:
While I plan to run accuracy tests next week, I was able to make some observations on the forecasts. First, I was surprised to see that the model was able to predict the decline in the price of the stocks of Sharps Technology. While it couldn’t get the exact price right, the model was able to show that the stock wouldn’t be able to come back up. Small companies’ stock prices are definitely much more volatile, but I hypothesize that the accuracy of the forecast for Sharp’s Technologies won’t be too far off from the accuracy of that of the more stable companies. For the other seven, the ARIMA model was definitely able to predict the overall trend of the stocks, except for Google, Amazon, and Tesla. For these three stocks, the ARIMA model predicted a much larger gain in their price than what happened in reality, and their ending price is almost $100 off from the stock price in reality. However, that is what my project hopes to discover – why did the actual stock price deviate from this forecast? These results were a mathematical prediction of stock prices, so it showed what these stocks would look like without any external influence.
Next week, I hope to run accuracy tests to get a quantitative idea of how much these prices deviated from stock prices in real life. After that I plan to start collecting news articles (my external influence) and determine whether or not they can account for the difference between these forecasts and the real prices. Thank you so much for reading and I’ll see you guys next time!
Reader Interactions
Comments
Leave a Reply
You must be logged in to post a comment.
Manasi Sharma says
I love how detailed you were in explaining how you got your ARIMA model to work after you ran into some trouble last week. I really enjoyed reading this blog post!
Aadya G. says
Never give up!! Do you think that your accuracy for smaller companies will be more or less accurate than for the larger ones? I loved reading this post, good job 🙂