Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
avoiding stocks that will be delisted

Is there any good quantitative way to select out stocks going to be delisted in the future? For example price decline of 80%, dollar volume average (if so what is a good rule of thumbs)?
Thank you

6 responses

For backtesting, you can try this in handle_data:

import datetime

for stock in context.stocks:  
    if stock.security_end_date < get_datetime() + datetime.timedelta(days=5):  # de-listed ?  
        context.stocks.remove(stock)  
    if data[stock].price < 1.1:  
        context.stocks.remove(stock)  

Note that you'll need to end your backtest about 5 days before the present, otherwise all stocks will be filtered out. Also, I would put SPY in your universe, so that handle_data gets called every minute.

@Grant: That's not a good way to predict stock delisting! What you're suggesting is to use 100% lookahead bias and in fact not predictive at all. Using pure lookahead bias also means that technique can not be translated to live trading.

@Ujae: As per Simon's comment in this thread, I don't believe there's a hard and fast rule for predicting stock delistings. That being said, I encourage others to offer suggestions here!

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 Jamie,

Correct regarding translating the technique to live trading--it won't work. However, it does predict delisting for backtesting, since if a stock gets delisted, it'll be dropped from the active Quantopian database. The idea here is that when a stock gets dropped from the Quantopian database, it is most likely due to a delisting that would have been scheduled within 5 days of its end date in your database. Is this a valid assumption? So, potentially it carries a look-ahead bias, but if a user is regularly checking his live-trading portfolio for potential delistings and managing them, then the bias should be minimal.

By the way, I think your colleague Seong recommended the same thing as I did here:

https://www.quantopian.com/posts/when-a-company-gets-acquired-my-portfolio-still-owns-shares-of-the-original-company-is-that-right

I'm guessing with the new pipleline, this problem is popping up more frequently. Any thoughts on providing a backtest helper function for flushing a stock out of a portfolio, if it ends up held after its end date?

Also, any plans to get data on scheduled stock delistings? Then there would be no risk of look-ahead bias.

Grant

Hi Grant,

The reality is, there's no way that you would ever get the end date of a stock before it actually stops trading! My claim that your workaround is not predictive was in regards to the fact that you can't actually predetermine whether a stock will become delisted using only information that you have prior to the delisting.

Regarding Seong's post in that thread, I'll have a chat with him later because I'm not sure that he was considering the lookahead bias when he posted it. Given that we understand it now, I think it's very important that others realize the dangers of using this in backtesting, because it really is a form of lookahead bias and could skew results. This is definitely a healthy discussion to have and highlights a weakness in our backtesting framework that we don't yet have a solution for.

I agree that the approach I posted above is kinda sketchy. For stocks that expire during a backtest, one could verify that they were scheduled to be de-listed and the announcement dates relative to the de-listings. This would be a check for no look-ahead bias in the backtest.

Maybe there are also cases where a stock listing goes "poof" without warning? When backtesting, you just have to end up holding the stock after it expires, but there should be some helper function to transact it (e.g. sell it at a specified price). I think once a stock stops trading, there's no way to sell it, right?

I found this discussion highly important.
If a stock is somehow dislisted from an index, it still should be considered the possibility of entering on it while backtesting the algorithm. Specially if we are comparing the performance to a benchmark which it timeseries considered that stock being part of it somewhere in time.