Found a pretty big issue in my backtesting. Any stock that is delisted in the present day is not included in the universe for the past. This introduces a lot of error into the universe creation and backtests. Is there a way around this like generating universe using the historically available stocks at that period?
Non Compete
Hi Panda Trader , I think AlgoFramework automatically removes Delisted Insights, see line 456 here:
https://github.com/QuantConnect/Lean/blob/master/Algorithm/QCAlgorithm.Framework.cs#L456
I dont know if you've already tried to do it with a non-AlgoFramework algo but that may be a possibility.
Panda Trader
Can you expand on what you mean by non algo frameworks? Appreciate the answer!!
Non Compete
By Algorithm Framework algos I meant the ones structured with Alpha/Universe/portfolio construction/ risk management models as described here:
https://www.quantconnect.com/docs/v2/writing-algorithms/algorithm-framework/overview
Using that framework isn't a requirement. You can run backtests just by inheriting from the QCAlgorithm class and using Initialize/OnData and optionally the other event handers (OnSecuritiesChanged, OnOrderEvent, OnEndOfAlgorithm) as described here:https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/getting-started
Newoptionz
Wow, well I have never really worked with the 'Algo Framework', I've been stuck in the ‘classic framework. I thought the whole idea of the Universe selection was to do away with this ’Surviourship bias', so it is strange that the more advanced ‘Algo Framework’ does this. It does make sense though if the ‘Algo Framework’ can trade those delisted securities in a backtest, before they get delisted. Then all is good.
Panda Trader
Thanks. I’m in the same boat though. I can’t think of a scenario where including this survivorship bias into the universe is a good thing. What’s the advantage? It’s an inherit flaw in the backtesting model and universe selec as it is now.
Louis Szeto
Hi All
LEAN will include past-delisted securities in universe selection, while removing the securities and liquidating your positions of them when they got delisted, so there is no survivorship bias, nor bug in this issue. To add past-delisted securites to your algorithm, refer to this post.
Best
Louis
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Panda Trader
Hi Louis,
We were able to get it to trade delisted securities by exluding “has fundamental data” from our course screener. Looks like that was the main issue, although now we are hitting the situation where multiple stock splits are not properly handled by LEAN.
Thanks,
Rohit
Louis Szeto
Hi Panda Trader
Thank you for reporting this issue, we are able to reproduce this issue. Please subscribe to this GH issue for its fixing progress.
Best
Louis
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Panda Trader
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!