Dear community,
I'm new to quantconnect and for learning purposes I am trying to build an algorithm that runs everyday 5 minutes before market close and collect the previous daily closing price of the 500 most liquid equities as well as the current price and then buy the 20 biggest losers.
The problem is that if I set "Resolution.Daily" then the algo is launched at midnight and the order is executed at the next open. While if set "Resolution.Minutes" then the algorithm is way to slow due to the high volume of data.
What I would like to do is keeping the Resolution but I would like it to happen 5 minutes before market close and not at midnight. Or if there is another way to solve this problem ?
Thank you in advance for your comments.
Nibraas Khan
You could consider using a scheduled event. Here is some more information:Â
https://www.quantconnect.com/tutorials/api-tutorials/scheduled-eventsÂ
Adam W
Using Minutely resolution and just calling pass in OnData should still keep the backtest running reasonably fast, then wrap the trading logic in a scheduled event as Nibraas mentioned.
You can also just store the last daily Close in a dictionary instead of repeatedly calling History to further speed things up.
Baptiste Cartier
Thanks for your suggestion Adam. I implemented both of your comments and it is working fine.
Thanks for your help.
Baptiste Cartier
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!