Avoiding Trades Before Earnings

Over my last 16 years of research, one of the most asked questions is should you not take trades before an earnings release. I could never answer this question because I did not have the data. I can easily recall trades were a stock came out with poor earnings and crashed 25%. But without testing this, I would still take stocks into earnings. Because that is how the testing was done.

A few months ago, I discovered that Quantopian has data for the earnings dates for stocks. I had been looking for a good reason to try out Quantopian and this looked like a good project.

A large dose of salt

Before I get into the details of the test, I must clarify one thing. I am not an expert Python programmer, which is the programming language you use in Quantopian. I have only been coding and using Quantopian for a few months. I did as many checks as I could on my code. But there is a larger than normal chance that there is a bug in my code. So as always verify these results yourself before using them for trading. You have been warned.

For you Quantopian experts out there. If I say anything wrong or could have done something better, please correct in me the comments below.

The Earnings Data

Quantopian provides free data from 2007 to 2013 on the earnings release date of stocks. I figured this gives a larger enough test timeframe to see if avoiding earnings was a good or bad thing.

Quantopian Information

Quantopian works very differently in some respects to how AmiBroker does. Because of this, some rules and stats will differ greatly from what you have normally seen in previous posts. Here are some differences.

Quantopian does not have S&P500 constituent data. They have data that they call the Q500US which is the 500 most liquid stocks. To read more go to The Q500US and Q1500US.

Entry and exit are done on a particular one-minute bar, starting with the 9:32am bar. That is what I will using.

Running a backtest is slow compared to AmiBroker. One test takes about 30 minutes vs. about 20 seconds in AmiBroker. Because of this, I was limited on the ideas I could test.

The Base Test

Since most questions about earnings have come from mean reversion traders, that is what I will be testing.

Dates: 1/1/2007 to 12/31/2013

Buy Rules

  • Stock is member of the Quantopian 500.
  • The 2 period RSI crosses under (1, 3, 8)
  • The close is above the 200-day moving average
  • Rank signals using 100-day Historical Volatility from high to low
  • Entry is on the next day on the 9:32 bar

Sell Rules

  • The 2 period RSI is over 80
  • If in position above 15 days, exit.
  • Exit is on the next day on the 9:32 bar

Base Results

I am not trying to create a great strategy but to have something to compare against.

The results are nothing to write home about.

Avoiding Earnings

Since a typical mean reversion trade is about 7-8 days. Here are the additional rules

Buy Rule Addition

  • Next earnings date is over 7 days away

Sell Rule Addition

  • If earnings are in two days, get out on the next day. We exit the day before earnings.

 

Results Avoiding Earnings

More Data

I have said this before but I just love results when they surprise me. I was expecting slightly worse CAR with a slightly better drawdown. In two of three cases the CAR came down dramatically while in all cases the drawdown and Sharpe Ratios got worse.

Spreadsheet

No spreadsheet with this post. Mostly because Quantopian does not make it easy to get data out.

Final Thoughts

Given these results, I will continue to trade my mean reversion strategies through earnings releases. This is why I test. My guess on what the results will be are often wrong.

One possible future test is also to avoid stocks shortly after earnings on the theory that stocks selling off after poor results will continue to sell off.

My next post will be a mini-review of Quantopian. Short preview: I will still be using AmiBroker for my backtesting.

Backtesting platform used: Quantopian

Good quant trading,

Visited 34 times, 1 visit(s) today

Click Here to Leave a Comment Below

MP - April 24, 2019 Reply

Seems weird that you are only skipping between 1 (RSI8) and 35 (RSI1) trades with your buy rule of avoiding entries the week before earnings.

Only one extra trade fell into this window for the RSI<8 test?

    Cesar Alvarez - April 25, 2019 Reply

    I thought the same thing. First, Quantopian (vs AmiBroker) makes it really hard to verify a test. From looking at a few trades what seems to be happening is this. For trades that you skip, that then allows you to enter some other trades. For trades that you get out early, that allows you to enter some other trades. Do this thought experiment. Imagine you had set the rule to RSI < 80. You would expect to be 100% invested. So even if you skipped a trade, there would always be one to take its place. Now this is not to say I could have a bug. Like I said, take these results with a huge grain of salt.

Thomas Musselman - April 24, 2019 Reply

Quantopian had a study that showed that 1 year backwards Sharpe was the #1 predictor of whether a strategy would do well going forward. #2 was overall Sharpe. Just a FYI since I’ve never seen a strategy comparison that evaluated them by likely forward performance by various criteria of backtests like CAGR, etc.

    Cesar Alvarez - April 25, 2019 Reply

    I have done some of my own research on this. This would make a good blog post. Need to put it on the list. Thanks.

James - April 25, 2019 Reply

Could you share a link to the Quantopian code please?

    Cesar Alvarez - April 26, 2019 Reply

    Part of the reason for not sharing is that I normally don’t. I did consider it but the code is ugly from me trying to figure it all out. Let me see if I can clean it up without too much work.

Mark - April 27, 2019 Reply

Let me know if you do this test on a more detailed level, it would be cool to compare findings.
For example, I found that signals with earnings in the 2 days before entry should be excluded, in my high-liquidity-less-oversold models (possibly PEAD or Post-Earnings Announcement Effect). Or that I shouldn’t short if earnings are scheduled for the day of entry.

    Cesar Alvarez - April 27, 2019 Reply

    At this time I do not plan on doing more.

GWC Inida - June 7, 2019 Reply

Good article, Your experience is useful for new share market traders.

Thomas E. Musselman - June 9, 2019 Reply

Also Zacks claims that good stocks (in their case zack rank 1 and 2) that historically have moved up on earnings releases do much better than those that move downward; don’t know that quantopian has this kind of data.

    Cesar Alvarez - June 10, 2019 Reply

    I wish I could get the Zacks and Norgate data integrated together. There would be lots of test I would want to do.

Brian - July 29, 2020 Reply

Hi Cesar,

I’ve been building my own strategy in Amibroker and is trying to build a code to sell a position before earnings. I looked everywhere online (including the AFL forum) and couldn’t find anything other than this blog. Would you be willing to share the code with me please?

Thanks,

Brian

    Cesar Alvarez - July 29, 2020 Reply

    The test was done using Quantopian. They have earning information. You need to have a data provider that gives you the earnings dates for stocks. Once you have that, then you need to get the data into AmiBroker. Once in AmiBroker it is easy.

Leave a Reply: