Back to Community
Check for recent IPOs

Does anyone know a way within the new Pipeline API to filter for recent stock issues? I can see that you can access a stocks IPO date through Morningstar data, but I'm not sure how you would go about determining how recent that date was compared to the current backtest date.

Any help would really be appreciated. Thanks!

7 responses

One approach is to use pipeline to save the list of all stocks on a given day (store in context), and then the next day, output the same list from pipeline. Any stocks in the new list but not in the old list are newly tradeable.

I'm not sure it is possible to use pipeline to identify IPOs on their IPO date and trade them, without waiting at least one day, since as I understand, pipeline needs to see at least one trade before it'll admit a security. Since it runs before the open, it won't include IPOs (perhaps someone can confirm this).

Steve,

The current backtest date can be found with get_datetime() (see https://www.quantopian.com/help#api-get-datetime).

I see ipo_date on https://www.quantopian.com/help/fundamentals#share-class-reference . I'm curious if get_fundamentals could be used to identify stocks on their IPO date? Or if works the same as pipeline, only admitting stocks after a first trade has been encountered? That is, if I'm understanding pipeline and get_fundamentals correctly...

Here's some code, but I'm not sure I trust it. It seems like there should be a lot more IPOs? You could try advancing the date by one day, to see if it then outputs IPOs 1 day after their IPO date.

Also, I don't think the fundamentals database covers daily changes all the way back to 2002.

Clone Algorithm
44
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: 57208b6c1d7402111499fb20
There was a runtime error.

Grant is correct with respect to the frequency of changes in the fundamentals db from 2002 - May 2014. In short, the records only update monthly for that time period.

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.

Hi Josh,

I don't understand the backtest I posted above. Shouldn't there be more IPOs (especially after May 2014, when the fundamental database is updated daily)? Have you confirmed that the ipo_date matches start_date across all equities?

And more importantly, should this ever be true:

fundamentals.share_class_reference.ipo_date == get_datetime()

Or is the API design such that it should never be true, since the first trade needs to be encountered by get_fundamentals before a stock would be admitted? So, perhaps my backtest is revealing a bug or bad data?

Grant

Hi Josh,

This seems like either a bug or a data error, correct? Shouldn't it always be true that ipo_date == start_date? And if get_fundamentals filters out securities until the first trade is encountered, since it runs before the start of trading, I shouldn't be seeing any securities at all, correct?

It seems that for a handful of stocks, the ipo_date occurs later than the start_date which would be incorrect, I think. Or maybe ipo_date and the start_date for a security are defined differently?

I re-posted the code, with a bit more output to the log, so that you can see what's going on.

Clone Algorithm
44
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: 572afd4867aa9510f3be7ccb
There was a runtime error.

The algo I posted above now shows no IPOs. Any idea why? Was something changed?

Clone Algorithm
4
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: 585e5d38dc509661e6128abc
There was a runtime error.