I want to implement a very straightforward strategy:
”Once a day, locate 10 stocks (out of all US stocks) with highest price change during last 100 days”.
To my understanding, it means I need to maintain a rolling window of trade bars gor each US stock, and inside “OnData” - when I get a daily bar - to add it to relevant rolling window and then to calculate a change for each stock and then submit needed orders.
The “coarse filter” function needs to return all stocks from US market + all stocks I currently invested in (otherwise they will be removed from the universe and I will stop get trading bars for them in “OnData”).
Does everything described above makes sense or there is a better alternative? In my backtests everything works (arguably not fast as I would like to but I can live with that) but during live trading I getting exception from time to time something about “algorithm spent more than 10 minutes and hence terminated”. How to implement the strategy described above without getting into this issue?
Mia Alissi
This corrected version adheres to Python's type hinting and fixes potential attribute errors. Make sure to verify the specific usage of
RollingWindow
andTradeBar
within your QuantConnect environment as appropriate for your implementation.Sources: Short Term Reversal Strategy In Stocks, Coarse Fundamental Top3 Algorithm, Momentum And State Of Market Filters, Coarse Fine Fundamental Combo Algorithm, Fundamental Factor Long Short Strategy
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!