Back to Community
Long/Short PEAD with News Sentiment and the Street's Consensus

This sample algorithm builds off the well known PEAD effect. It uses the Street's consensus (average analyst estimate) and compares it to the actually reported earnings after an announcement. In comparison to traditional PEAD strategy, this one also uses NLP based news sentiment to validate long/short positions before entrance (long on positive surprise and positive sentiment and vice versa for shorts).

This one is based off of Wall Street analyst estimates instead of the crowd which I've released a strategy on before.

Strategy Details:

  • Data set: Analyst Earnings Surprises by Zacks, and news sentiment by Accern
  • Weights: The weight for each security is determined by the total number of longs and shorts we have in that current day. So if we have 2 longs and 2 shorts, the weight for each long will be 50% (1.0/number of securities) and the weight for each short will be -50%. This is a rolling rebalance at the beginning of each day according to the number of securities currently held and to order.
  • Capital base: $1,000,000
  • Profit and Loss limits are set to 6%
  • Days held: Positions are currently held for 4 days but are easily changeable by modifying 'context.days_to_hold'
  • Percent threshold: Only surprises between 0% and 6% in absolute magnitude will be considered as a trading signal. These are adjustable using the minimum and maximum threshold variables in context.
  • Earnings dates: All trades are made 1 business day AFTER an earnings announcement regardless of whether it was a Before Market Open or After Market announcement
  • Universe: It filters for the top 1500 liquid securities using the mechanisms found in the Q1500 (https://www.quantopian.com/posts/the-q500us-and-q1500us)
Clone Algorithm
304
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57dab5aec8cf8010253f9c09
There was a runtime error.
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.

21 responses

Here's the OOS version of the same strategy. Feedback and thoughts are welcome.

Clone Algorithm
671
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 579618eb2850261003463958
There was a runtime error.

I'm wondering if it's possible to make the trade the second the earnings announcement is released. Hopefully that'll beat all of the fundamental/value investors who have yet to even open the report.

if it's pure out of sample test, shouldn't the sample period start at 2014-01-09 instead of 2012?

Diana,

Thanks for pointing that out. The original was posted to show a full backtest over that time range. Here's another version to show starting 01-09-2014.

Clone Algorithm
671
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 579b5a1482f481127aa77553
There was a runtime error.

I am curious about a few assumptions made in the algorithm: 1) what's the distribution on news sentiment? approximately how many events have sentiment >0.3 and how many events have sentiment<-0.5; 2) long/shorts position are determined using symmetric earnings surprise cutoff, i.e. positive or negative surprise with an absolute magnitude with in 6%, but empirically there are more earnings announcements with positive surprise than with negative surprise, what will the results be say choosing the events in the top and bottom quintile or tercile? 3)if i understand it correctly, current long (short) portfolio select stocks with positive earnings surprise/positive sentiment (negative earnings surprise/negative sentiment), i.e. stocks that have a market-wide sentiment in line with their earnings outcome, what about long on those with negative sentiment/positive surprise and short those with positive sentiment/negative surprise. these stocks on average should have amplified immediate market reaction, as well as prolonged drift. yet it seems to me that the current strategy mainly focus on the positive auto-correlation feature between quarter t earnings surprise and quarter t+1 earnings surprise, so i'm not so sure whether changing the long/short portfolio selection criteria will have as big an impact, compared to say focus on market reaction to current quarter earnings release, or PEAD over (+1, +61 or 71) trading day period, the latter should cover the next earnings announcement though.

Is there a way to trade this soon after the announcement (i.e. same day for Before-Market announcement and next day for After-Market? I tried appending this post-earning-announcement date column to the pipeline, but the pipeline output doesn't show this column. Is there something wrong in my logic or command?

pea_date = EarningsSurprises.asof_date.latest.timedelta(days=1) if (EarningsSurprises.act_rpt_code.latest=='AMC')  else EarningsSurprises.asof_date.latest  

2) Also, how timely is the Zacks data released (especially for BMO announcements) - can this be traded at Market Open of the same day as BMO announcement?

3) Why did you use EventVestor date (yet another provider) instead of using the Zacks date fields: asof_date and act_rpt_code. Is there an issue with the Zacks date fields?

Diana,

Those are some amazing questions. I think it'd be awesome if you could explore those a bit and post here with what you find! I'm happy to collaborate and help in with that research. Shoot me an email at SLEE @ Quantopian.com

Kiran,

I have an example that adds act_rpt_code and asof_date to the pipeline but hopefully these responses can help clear up some confusion:

  1. You can add the act_rpt_code to determine whether or not an earnings announcement happened at AMC (after market close) or BMO (before market open). I believe adding conditionals to a pipeline column won't have the affect you desire. Please see the Filters tutorial here.
  2. The timeliness is different for both backtesting and live trading. For backtesting, we make the data available 1 day after the actual report date and time. We do this as a conservative estimate. For live trading, it is slightly more real time as the current day's data is for yesterday's earnings surprises. E.g. You will have the AMC earnings reports for yesterday but not the BMO.
  3. We do have a factor from Zacks called BusinessDaysSinceEarningsSurprisesAnnouncement but it is currently incorrect and we're working on fixing it. Until then, we've made the EventVestor dataset available as a substitute.
Clone Algorithm
671
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57a0a6baf223f51018b5eda4
There was a runtime error.

Seong Lee,
Will certainly do so!

Thanks Seong,
How do i screen for symbols that have announced before the "run date" (i.e. the date in run_pipeline(pipe, start_date='2016-03-03', end_date='2016-03-03')? I need to research the price movements the date after announcement. My filter is ..

filter = (asof_date == "run_date" & act_rpt_code eq "BMO") | (asof_date == "run_date" -1 & act_rpt_code eq "AMC") #since the system delays the asof_date by 1 day for backtests.

Also, for live trading, the Zacks Website releases BMO data before market opens. Are you sure the API does't provide it? That would be useful for same-day trading.

Hi Seong,
In this algo, how do i enter trades soon after the announcement (i.e. AMC previous day or BMO same day)? It seems like the eventvestor factor "BusinessDaysSincePreviousEarnings" is still a day late. I looked at some of the other PEAD strategies and they all have the same issue.
- Could you point me to example code of a PEAD strategy that triggers the trades soon after announcement, at Market Open?

thanks
Kiran

Kiran,

Our earnings calendar datasets typically update around 5 or 6 AM EST and, in the case of Zacks, it is a daily roll-up of yesterday's data. So in many cases the Market Open trade of the current day's BMO earnings is not a reliable signal.

As for the filter, we're currently implementing a fix for Zack's BusinessDaysSinceEarningsAnnouncement factor that will make things a lot simpler. I'll update this post with that once it's out.

Seong

Thanks, let me know once you release the filter with same-day trading post-announcement - whether you use Zacks or EventVestor calendars doesn't matter, so long as it triggers timely trades upon Market Open.

Kiran,

For Zacks and EventVestor, the earnings calendar data is a daily roll-up of yesterday's data. So for today, 8/25/2016, you'll receive earnings announcements for 8/24/2016.

That being said, the Zacks BusinessDaysSinceEarningsAnnouncement factor has now been fixed so you'll be able to use that instead of EventVestor's BusinessDaysSincePreviousAnnouncement factor.

Hope that helps,
Seong

So that means, we backtest or trade same-day as the "before-market-open" announcements (i.e. announcement at 8am EST today and Buy-at-Open at 9:30am) on quantopian, correct?

Hi Kiran,

It's backtest or trade 1 business day after. So you'll get yesterday's "before-market-open" announcements today. Of course, the businessinceearnings factors will reflect that and be 1, not 0.

Thanks Seong,

As a work-around to this limitation, can i use the "File Date" as a timely trigger of Earnings Announcements i.e.

if ("File Date" == yesterday), Open a Position  
  • The "File Date" seems accurate for backtesting, but not sure if it's accurate for walk-forward Live Trading - pl confirm.
    • Also, is there a sample algorithm that uses the File Date as an example?

thanks
Kiran

Hi Kiran,

Whether or not you use the File Date or the BMO factor, I believe you'll get the same result. You will get yesterday's data, today.

Seong

The algorithm has been updated to use the Q500, here's an out OOS version of that.

Clone Algorithm
304
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57dab17002492612f082c1ee
There was a runtime error.

I notice that the performance of this version (using street's consensus) looks inferior to the one using Estimize's. Is it because Estimize has more accurate estimate? Also, is there an ETA to bring Estimize back to Quantopian?

@seong lee
If we want to run a variation of this algorithm on paper trading, then do I have to change the code?

Hi Seong Lee,

Thanks for sharing this.

I am having trouble running a backtest when I clone your algo. The error is as follows:

"NotImplementedError: couldn't find matching opcode for 'and_bbd'
There was a runtime error on line 81."

The code on Line 81 is as follows:
results = pipeline_output('earnings')

Any clue what could be wrong here and how I could fix it?

Thanks!