Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
EarningsCalendar Data is missing many columns available in Research's earnings_calendar

In the attached notebook, I am able to determine whether a stock is reporting After Market Close or Before Market Open among many other columns using earnings_calendar for dataset. For example, I extracted that on 1/27/2014, AAPL had an AMC earnings report.

However, when I go to a live algorithm, I can no longer import earnings_calendar (since it is only for research)

from quantopian.interactive.data.eventvestor import earnings_calendar as dataset  

If I change the namespace to quantopian.pipeline.data.eventvestor like below, I get an error saying: "Runtime exception: NotPipelineCompatible: eventvestor.earnings_calendar is not currently available in the Pipeline API"

from quantopian.pipeline.data.eventvestor import earnings_calendar as dataset  

Importing EarningsCalendar (below) seems to only provide the next earnings report date and the previous earnings report date. This is a problem because the date does not pinpoint whether the company will report before or after the market day. How do I get the other columns that are available in Research's earnings_calendar but does not seem available in the algorithm's EarningsCalendar?

from quantopian.pipeline.data.eventvestor import EarningsCalendar  
7 responses

I am also trying to figure this out! I need to know if the release is going to be before or after hours.

Hi Matias, I was able to figure this out. You can retrieve the data using: EarningsCalendar.previous_calendar_time.latest. Then you can a python .loc to get a specific stock in your pipeline output's earnings time.

One thing that I noticed is that the data was just recently changed such that if a stock reported yesterday after market, then previous_calendar_time = 0. Before, previous_calendar_time = 1 for a stock reporting yesterday after market. Are these type of data changes announced somewhere? I wasted many hours trying to figure out why the heck my algorithm's backtest from last week varied from the backtest yesterday despite having the same code. Additionally, when deployed live, it would be very dangerous to be have earnings date data change on you since earnings are such volatile events. I really think Quantopian should send an email or notification if a dataset you purchased is modified.

Hi Sofyan,

We did recently apply a change to the way that calendar times were applied to the BusinessDaysUntilNextEarnings and BusinessDaysSincePreviousEarnings factors. Previously, the factors were treating all announcements scheduled on day N as the same business day, regardless of when they occur. We didn't think that this made sense because on day N, you wouldn't be able to distinguish between events that had already occurred (in the morning) and events that are scheduled to happen after the market closes. As such, we changed the design such that anything occurring after market open is considered to be scheduled on the next trading day - essentially treating the business day for day N as 4pm on day N-1 to 4pm on day N (Eastern Time).

The change hasn't yet taken effect in research, but it should be this week. Initially, this is why we delayed the announcement, but I see your point regarding live trading with the dataset. I just sent out an email to subscribers.

I apologize for the lack of communication.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Jamie, thanks for the reply. This update is definitely an improvement to the data and I appreciate the accountability.

Thank you very much Sofyan! I hope you can answer one more question I have...

The strategy I'm working on takes two different approaches to trading when earnings are released before market open vs after market close.

earnings_type = EarningsCalendar.previous_calendar_time.latest  
    if earnings_type == "Before Market Open":  
        earnings_type = 0  
    elif earnings_type == "After Market Close":  
        earnings_type = 1  

In the notebook examples the values for the variable calendar_time is either one of those two strings, but I'm not getting any matches with this. How would I go about classifying it now?

Hi Matias,

EarningsCalendar.previous_calendar_time.latest is a Classifier. I would recommend going through the Pipeline Tutorial to understand how these work.

In general, this is a good example for assigning labels to stocks based on the previous calendar time.

from quantopian.pipeline import Pipeline  
from quantopian.research import run_pipeline  
from quantopian.pipeline.data.eventvestor import EarningsCalendar  
from quantopian.pipeline.factors.eventvestor import (  
    BusinessDaysUntilNextEarnings,  
    BusinessDaysSincePreviousEarnings  
)
from quantopian.pipeline.filters.morningstar import Q1500US

def make_pipeline():  
    amc = EarningsCalendar.previous_calendar_time.latest.eq('After Market Close')  
    bmo = EarningsCalendar.previous_calendar_time.latest.eq('Before Market Open')

    pipe = Pipeline(  
        columns={  
            'after_market_close': amc,  
            'before_market_open': bmc,  
        },  
        screen= (Q1500US() & (amc | bmc))  
    )  
    return pipe  

Then, you can attach this pipeline to your algorithm and look at the pipeline output to get stocks by previous_calendar_time.

Thank you very much! This has been very helpful.