The stocks ownership gives you the right to share in the profits of the company. In an ideal world, the price of the stock should be highly dependent on the earnings of the company, as it is a discounted future profits. If, at some point, a company earns more than previously — it might mean that the growth of a company is accelerated and the stock should be priced higher. That's why — among some other financial indicators to follow — earnings per share (EPS) is one of the most important one. Every quarter analysts make predictions on the company profits (or losses) and then check those predictions vs. actual reported EPS. If the company is doing better than predicted — it should cause the stocks price increase, and vice versa.
In this article, we aim to test this at scale — for hundreds of stocks that have reported earnings in 2020 Q2. We will check the dependency of a stock's price fluctuation vs. actual EPS, predicted EPS, and Surprise (= actual_EPS/predicted_EPS-1). Below is a quick overview of the sections and topics covered in the article:
In the Scraping Yahoo Finance: Earnings-Per-Share
section, you'll learn how to obtain the earnings-per-share information for a wide range of companies for a specified period of time (starting with one day), scraping it from the Yahoo Finance website. Then, in the Packing Everything in One Scrape Function
section, you'll embody everything you learned in the previous section into a single function to get a weekly stats on the dates and EPS. After that, in the Getting Stock Prices for a Company
section, you'll look at how you can get data on stock returns and volume for a certain company. In the Getting S&P 500 Stats
section, you will look at how to obtain S&P 500 data to evaluate how a certain symbol is doing against the index. In the Getting Stock Returns and Volume from Yahoo Finance
section, you'll learn how to obtain data on stock returns and volume for all tickers found in Yahoo finance. In Merging All the Pieces Together
part you will get the combined dataframe of the stats from all previous parts. And finally, in Analysis and Visualisation
section you will see the examples of graphs built on the dataset.
This article is the fourth part in the series that covers how to take advantage of computer technologies to make informed decisions in stock trading. Refer to part 1
to be guided through the process of setting up the working environment need to follow along with the examples provided in the rest of the series. Then, part 2
covered several well-known finance APIs, allowing you to obtain and analyse stock data programmatically. In part 3
, you explored whether stock market is influenced by the news.