It’s easy to get carried away with the wealth of data and free open-source tools available for data science. After spending a little bit of time with the quandl financial library and the prophet modeling library, I decided to try some simple stock data exploration. Several days and 1000 lines of Python later, I ended up with a complete stock analysis and prediction tool. Although I am not confident (or foolish) enough to use it to invest in individual stocks, I learned a ton of Python in the process and in the spirit of open-source, want to share my results and code so others can benefit.
A common misconception is that the market cannot be predicted and that hedge fund managers are no better than dart-throwing monkeys. Many academic research papers back up this claim with data. This is an overly simplistic view. Just because some markets cannot be predicted under some experimental settings, such as equities traded on a daily basis, this does not mean no market can be predicted in any setting. Let us try to get an intuitive understanding of what it means to predict the market.
With Python code to scrape, extract, transform and load it into a HDF5 data store to please your future self.
This post will go through the process of gathering and cleaning this data followed by an exploratory analysis examining price trends and the impact of events on prices using data from the IEX API and scraped events from financial news sites.
“Buy the dip” — it’s a frustratingly simple piece of advice. Like most pieces of advice, it’s easier said than done and the giver of such advice has probably not attempted to practice what they preach. It induces FOMO, which leads to the “hope trade”, when the “hope trade” goes awry you’re stuck as the “long term investor” who “really believes in the company’s mission”.
The bot is written in Python and relies on two core libraries for the majority of its functionality: robin-stocks and ta. robin-stocks is a library that interacts with the Robinhood API and allows one to execute buy and sell orders, get real time ticker information, and more. ta is a technical analysis library that also incorporates the Python Pandas library to generate indicators from stock data.