Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Accounting for events like IPO and Earnings

I'm writing a combination of mean reversion and momentum and wondering if anyone had ideas about how to avoid companies that have either recently IPO'd or released earnings either that day or the day before. Basically, these are external events that cause me to usually take big losses. I am already using set_universe, but recent IPO's are appearing. I would like to avoid these companies because they are so volatile. I would like to avoid companies that have just reported earnings as well due to the volatile nature there as well.

I look forward to hearing everyone's ideas about how to approach this. One thing I am contemplating is an if statement to exclude companies with a starting trade date before x. However, I am stumped on the earnings problem. I would like to wait at least 2 hours after an earnings release before trading the stock.

2 responses

Ben,
This is something I am working on as well, I have a partial solution, but ran into a wall.

I modified an earnings date scraper written by Gus and uploaded it to Quandl via their toolbelt. The good part is that there's an earnings date time series for every stock that gets updated daily. The bad news is that it's hard to use the fetcher to get several stocks at once. The problem is that the fetcher can't grab a separate file for each stock, and the indexes don't match for each data set, so the python api throws an error if you try to concatenate them into a single call.

An idea might be to use the data sets I made to get the data for the stocks you care about, and format it into a format that can be easily grabbed by the fetcher.
The earnings date codes have this format DAVID_EDWARD/EARNINGS_{ticker symbol}

This backtest is an example with 1 stock, if the gap on MMM's earnings date is at least +-.2%, it buys or sells with 4X leverage and sells 350 minutes later. It's a start, but It would be nice to have an easy way to get this data for several stocks at once.

David

I'll let you know what I come up with. Your method is intriguing, and I may have an idea. I plan on spending a couple hours tomorrow trying to conjure up some type of solution. I feel like earnings dates could be a really useful tool as part of the API, so maybe that functionality will be implemented sometime. My other solution would be an HTML parser and just get the data myself, but I do not believe there are any supported at this point in time unfortunately. I'll report back tomorrow, and thanks for the lead.