Back to Community
BusinessDaysUntilNextEvent gives incorrect results with custom dataset

In an attempt to replicate the functionality of the now-defunct EventVestor factors BusinessDaysUntilNextEarnings and BusinessDaysSincePreviousEarnings, I've scrapped earnings data for 2020 from the Yahoo! Earnings Calendar, put it into a CSV file (the complete CSV file can be found here), and imported it into Quantopian's self-serve data setup. From the pipeline, the following fields can be accessed:

Date, Estimate, Actual, Surprise  

I then use the factors BusinessDaysUntilNextEvent and BusinessDaysSincePreviousEvent with my data to get the days until the next earnings release and the days since the last earnings release:

next_earnings = BusinessDaysUntilNextEvent(inputs = [earnings_data_2020.date])  
prev_earnings = BusinessDaysSincePreviousEvent(inputs = [earnings_data_2020.date])  

The BusinessDaysSincePreviousEvent factor gives the correct number of days since the last earnings release, but the BusinessDaysUntilNextEvent factor just gives the negative of the value returned by BusinessDaysSincePreviousEvent, e.g. if BusinessDaysSincePreviousEvent returns 7 for a security, BusinessDaysUntilNextEvent returns -7.

How can I get the correct functionality from BusinessDaysUntilNextEvent?

3 responses

Hi Alex,

First off, thanks for providing so much detail in your question. I downloaded the .csv file you linked to and replicated the issue. Judging by the contents of the file, I think there may be a disconnect between the requirements of the Primary Date column and what has been provided in the file. Here's an explanation of the Primary Date from the Self-Serve documentation:

The primary date column stores the date to which each record's value(s) applies. This is generally the last complete trading day after which you learned about the record. For instance, if you learn about a record at 8AM ET on 07/25/2019, the asof_date should be 07/24/2019 since that's when the most recent complete trading day occurred. The primary date is used to populate the asof_date in pipeline, which you may recognize from other pre-integrated datasets on Quantopian.

In the context of your example, it appears as though the Primary Date is being populated with a column of data that actually represents the expected (or actual) earnings report dates of each company and fiscal period. Instead, you should provide a file with 2 columns of data per record. One column (which you should select as the Primary Date) should represent the last complete trading date after which the report date was announced or learned. The other date column should contain the estimated or scheduled report date. Notably, the report date should be later than the Primary Date value if the report's publication is scheduled in advance. If both of these columns are provided, Pipeline will use the Primary Date to position the record in a simulation. You should then be able to use the other date column (i.e. report_date) with BusinessDaysUntilNextEvent.

Do you have access to dates representing when the report date was announced?

Jamie

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,

Unfortunately, I don't have data for when earnings report dates are announced. Do you know of any sources for that information?

I don't, no. One thing you could do is try to approximate when they might have been known. However, that is likely to be a source of lookahead bias, so you may want to avoid it. Does Yahoo! provide any information on when the list is updated? I wonder if all the earnings dates were added at one time or whether they were added one at a time.