Hi QuantConnect Community,
So my algorithm right now is just trading one security. I know I can create a list of equities, but I wanted to know if it is possible to trade a list of equities based on the indicator I have set up. Do I need to add data for the rolling window for each security? Or can I just say add a consolidator for the equities in my list? For the market orders and stop market orders, is it possible to just buy a security when the indicator is triggered, or do I have to select a specific symbol? If you need clarification, as I know this is confusing, please let me know.
Douglas Stridsberg
For every security you intend to trade, you will of course need to subscribe and add the necessary data for it. There are a few ways to structure this, but perhaps the most intuitive way is to simply iterate through the list of securities and check the trade conditions for each separately.
Nicholas Stern
So is there a way to structure it where I don't have to individually check the trade conditions of each separately?
Douglas Stridsberg
Yes - look up "python for loops" in your favourite search engine. You should have a list of tickers and iterate over them, executing your trade logic on each ticker. Your "Window" variable can be turned into a dictionary of rolling windows, making it easier to add and access a rolling window for each ticker. Your "TradeBarHandler" method can simply look at what the tradebar's symbol is and decide which rolling window to add the data to.
Nicholas Stern
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!