Hi all,
I'm trying to trade on a universe of strictly the top 25 most liquid stocks of the day, and I'm using a universe selection filter and self.ActiveSecurities in tandem to try to accomplish this. However, as evidenced by the debug statement in this sterilized backtest, the number of items in ActiveSecurities goes up at a steady pace through the duration of the backtest. Why is this; and how can I stop it?
Dan
Louis Szeto
Hi Dan
ActiveSecurities includes not only the selected ones from the Universe Selection method, but also the invested securities. Therefore, your backtest is re-investing the ones within your portfolio plus the newly added stocks from the selected universe. To solve this, we can introduce and call a global list holding the filtered stocks from the universe.
We also recommend only liquidating unwanted equities to avoid excessive ordering fees. Please find the attached backtest as an example.
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.
Dan Kim
Thanks for your support Louis. But even with your proposed changes, logging the instruments in the portfolio still shows that the number of securities in the portfolio grows over the time of the simulation. Can we be sure there's not a [memory] leak in LEAN causing this?
Dan Kim
I googled and read some other forum posts and now I have a suspicion that it takes 2 data bars, at whatever resolution, worth of simulation time for a liquidation operation to complete.
I'm trying to build a system where liquidation happens shortly after market open and new positions are taken shortly again thereafter. I guess this is more complicated to do with Daily resolution data than with say, hourly. Can someone confirm if my thoughts are correct?
I guess the solution for me would be to have the algorithm request hourly resolution data and consolidate bars where needed.
Vladimir
Dan Kim,
Try this way.
Vladimir
Dan Kim,
In fact, in order to trade 10 minutes after the market opens,Â
we have to subscribe to the minute data.Â
Dan Kim
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!