Extracting Historical Earnings Data Using Python

Earnings Announcement Strategies Extracting Earnings Dates

By Milind Paradkar

Earnings announcement events are important events for investors and traders. Earnings results of a company tend to determine the future price direction of a stock and hence these are closely followed and analyzed by them. The period around the date of the earnings announcement sees increased volatility in price and the traded volume of the stocks. Traders can take advantage of this by using different earnings announcement trading strategies.

You can check the “Screener” page on the Quantpedia site where they have listed different earnings announcement trading strategies. The “Screener” page on Quantpedia categorizes hundreds of trading strategies based on different parameters like Period, Instruments, Markets, Keywords etc. Quantpedia has made some of these trading strategies available for free to their users.


Some of the earnings announcement strategies listed on the Quantpedia site include:

To formulate and backtest any earnings announcement strategy, we need the historical dates of earnings release for any given company. Once the dates are extracted, an earnings announcement strategy can be formulated using these dates and other important data like price-volume history, historical performance numbers like sales, profit margin, net margin etc.

Earnings release dates can be obtained from different sources; a financial markets portal being one of such sources. The goal of this article is to extract the historical earnings dates from a popular financial markets portal using Python.


Corporate Events Table

Python Code for Extracting Historical Earnings Release Dates

Step 1: We first import the required libraries; requests, pandas, and BeautifulSoup. We then copy the URL from the financial market portal for the particular company.

We apply the requests.get function from the Python requests library (which is a simple HTTP library) on the URL which creates a response object (named as “page” in the code). One can check whether we were able to successfully execute the function by checking the status code. The contents of the “page” object can be viewed using the content method.

Step 2: In this step, we use the BeautifulSoup library for pulling the events table from the HTML. Some basic knowledge of HTML is required in this step. We inspect the HTML page to find the exact location of the events table. We apply the “find_all” method on the respective table class.

Step 3: Note that find_all returns a list. Hence we loop through or use list indexing to extract the required content. We parse the body of the table to grab each row, and extract the values from its columns, and then move on to the next row.

We create two separate empty Python Lists, namely date_list and event_list, which we will populate with the event dates and the event names respectively using the Python For-Loop. The values obtained using the text method is in the Unicode format and we need to convert them to string type.

Step 4: In the final step, we merge the two Python lists into a Pandas data frame and select only the “Quarterly Results” and the “Audited Results & Dividend” events. Let us print the earnings release dates of the latest four years.



One can extract earnings release dates using this Python code and then use other relevant data to build earnings announcement trading strategies. We will explore such trading strategies in our upcoming post. Meanwhile, you can check other quantitative trading strategies listed on our site. As always, we appreciate the likes and shares for our posts. Keep them coming!

Next Step

If you want to learn various aspects of Algorithmic trading then check out our Executive Programme in Algorithmic Trading (EPAT™). The course covers training modules like Statistics & Econometrics, Financial Computing & Technology, and Algorithmic & Quantitative Trading. EPAT™ is designed to equip you with the right skill sets to be a successful trader. Enroll now!

Download Data Files

  • Extracting Earnings Dates – Python Code

Login to DOWNLOAD these files for FREE!

Existing Users Log In