I Made A Stock Market Web App

*Update: As of Jan 2023, Yahoo! Finance made fundamental changes to their API, the source from which the app pulled its data. As a result, the app no longer works as intended, but I think the ideas I share in this post are still relevant and worth remaining published.

I’ve spent a large chunk of my free time this summer getting back into my interests in the stock market and investing. In May and June, I learned many new facets of algorithmic trading, financial indicators, and the application of time series analysis, as well as leading investors’ philosophies of the stock market. With my renewed interest and a fresh outlook, I tried to apply the new things I learned by researching various holdings.

But I immediately noticed something: many stock market websites bombard you with extraneous information and distracting links to long-winded and trivial “analysis” articles. I thought that a streamlined dashboard would make stock research much easier, so I made a web app to do just that.

Screenshot of in-browser application. Interactive version is hosted through Streamlit and is on my GitHub

How does the app work and what does it do?

The app is written entirely in Python and uses the Yahoo! Finance API to retrieve information about a stock. It combs through Yahoo! Finance’s ample information to give a clean and concise summary of a user-input asset and its historical price data - it even includes an option to pick a custom date range, a feature Yahoo! Finance does not support. I also added options to plot Bollinger Bands, compare the asset’s performance to the S&P 500, and predict the asset’s future share price using a neural network (FBProphet).

I highly recommend playing around with the app to get a better idea of what it can do!

What have I learned?

First and foremost, this project has been a great exercise in thinking like an app developer instead of a statistician. I consistently found myself retooling my code to maintain readability and scalability as I added more features. By doing so, I learned the nuances of branching and merging in GitHub: during development, I kept simultaneous branches to see how different versions of the app would look in Streamlit’s web client.

The utility of time series analysis relating to the stock market encouraged me to include a neural network in the app. I initially anticipated that the FBProphet model would give practical insight into future stock prices, but I quickly noticed some caveats. FBProphet observed the decreasing share prices in the current bear market and consistently predicted stock prices to trend downwards indefinitely. Although its future predictions are almost certainly going to be incorrect, it did highlight some interesting patterns. For example, Microsoft’s stock has performed relatively well on Wednesdays and has seen pretty large swings in price over weekends in 2022 - that may be useful information for someone out there.

The flaws of the FBProphet predictions do a phenomenal job demonstrating the dangers of blindly trusting a deep (or machine) learning model, especially when you don’t understand what’s happening behind the scenes. And that point conveniently segues into the last thing I wanted to mention. In tandem with making the web app, I read ‘University of Berkshire Hathaway: 30 Years of Lessons Learned from Warren Buffett & Charlie Munger at the Annual Shareholders Meeting,’ which shared advice from two of the most successful investors in American history. The book includes keen commentary and analogies about investing, along with some candid life advice. Throughout the years, Buffett and Munger have continually dismissed academic theories and fancy technical indicators about the markets, claiming that through trial and error, their track record has been much more efficient than by “looking for answers in chicken tracks.” Needless to say, they are firm believers in independent thinking and learning from mistakes, both from themselves and others. In life, but especially in investing, brainlessly following any one model (way of thinking, or one-size-fits-all approach) can cause more problems than it solves, as “every problem looks like a nail to the man with a hammer.” Buffet and Munger’s approach isn’t objectively the best investing strategy - both of them have made many mistakes in their careers - but I wholeheartedly agree with their advice to make the most of our mistakes and pursue a life of learning; our greatest investments are ultimately ourselves.

Previous
Previous

Introducing Spotible

Next
Next

Method of Moments and Maximum Likelihood Estimation