Hello everyone,
I was wondering what the best way would be to filter equities in a Universe by returns over the past 12 months would be. Should I just perform a historical data request and calculate the percent returns manually (in that case, is there a way to request data for only a single day and not a period of time)? Would it be better to use rolling windows for this? Is there some other method? I would appreciate any assistance!
Also, is there some way to stop the algorithm through the API during live trading without having to do it outside of code? Or is there some sort of kill switch I could set up that stops the algorithm and liquidates all held assets?
One final question: How can I access the open and close times for a market instead of just one symbol. I want to schedule a function at 15 minutes before close, and I know I can do this by providing a specific symbol, but I'm using a dynamic Universe, so there is no single symbol that represents what I want to schedule, and the function I want to schedule should only run once (it liquidates the entire portfolio) not for everything in the Universe. Should I just pick an equity in the market I want to schedule around? Is there a better way to schedule this/access the market open/close times? Thanks to anyone who offers advice!
Varad Kabade
Hi Matthew Kobrick,
We recommend using the roc indicator created with the help of the indicator constructor implemented using the SymbolData class and using the coarse filter function. We have implemented a demo algorithm for you. Note that to avoid repeating history requests for the same symbol, we are storing the SymbolData objects in a dictionary keyed by the symbol.We can use the Quit method of QCAlgorithm class to stop the algorithm if our quit conditions are met.
We can add an "anchor" Symbol, e.g., SPY when creating a scheduled event.
Refer to the attached backtest.
Best,
Varad Kabade
Matthew Kobrick
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!