I'm developing an indicator that is either greater than 0, or less than 0. I'm using a universe selection, and not picking single stocks to trade. how can i set this up in OnData()?
pseudocode:
if indicator <= 0
if not paused, pause trading
if invested, liquidate
return
if indicator > 0
if paused, resume trading
Thanks!
Tim Bohmann
Does this code allow me to keep my universe of symbols, but still move in and out of positions? ie When I liquidate, do the symbols from SetUniverseSelection remain in Portfolio object even if I'm not invested?
This code seems to suggest that. I'm just trying to understand the different objects.
var holdings = Portfolio[symbol]; if (!holdings.Invested) { MarketOrder(symbol, 10); } else { MarketOrder(symbol, -holdings.Quantity); }
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.
Yiyun Wu
Hi Tim,
Could you please specify how do you want to combine the indicator and universe for your strategy? We can provide a better help if you could clarify your strategy and functions, or attach your backtesting code below. Here is an example strategy of using a combination of indicator and universe, which might help.
For second question. The Portfolio property is only the collection of SecurityHolding objects for accessing to the holding properties. Universes are stored in the IDictionary<string, Universe> UniverseManager. If you would like to keep or access your universe of symbols, We can loop through the dictionary entries to keep or access symbols in your universe. Here is the forum discussion for how to get symbols in universe.
Thanks
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.
Tim Bohmann
I looked over the provided examples, but I'm still trying to figure out where to do this. If my alpha is emitting positive insights as long as my indicator is positive and negative insights as long as my indicator is negative, I want to do:
(in onData?)
if alpha is positive
if not invested, invest at target percentage (stay long, don't keep buying)
if alpha is negative
if invested, liquidate symbol, don't remove from universe and don't go short
Is QCAlgorithm::OnData the handler for insights? According to the Framework model, I should be handling orders in my execution model. Is there a model already setup that will do the above logic?
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.
Jared Broad
Hi Tim, yes most of that is handled in the modules provided. Your primary job is to create the signals in the alpha model, and then I suggest the other modules we supply should be enough. If your strategy is literally that simple above you don't need the framework.
First please read the Framework documentation thoroughly. Its a fairly abstract series of concepts so it might be hard to grasp. If not clear I'd recommend the book, "Inside the Black Box".
This is a good example of a custom alpha model with stock other models.
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.
Tim Bohmann
I'm not sure what's wrong. Jared, can I send you my backtest link and have you take a look?
The model is doing 10000 trades in one day and failing out/stopping. I would rather not post here at this time, as this is an idea for the competition, and not sure I'm coding it right.
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.
Tim Bohmann
disregard. I'm going in a different direction for now.
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.
Luca Napo
For me .the Search API tree just doesnt work anymore since the update. I input searches and nothing happens..
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.
Ian Larson
I can't delete projects. I'd like to be able to delete ones I know have buggy code, and organize them into folders etc based on the algo. I've been cloning projects to build the next iteration of an algo each time so that I have the previous code for reference in case I break what I'd been working on.
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.
Gkiwi
I don't think this new terminal design is ready for live use. There is no discernable improvement to me. Now, it overheats my laptop now as soon as I start the terminal and keyboard editing lag has increased. Navigating is clunky having to close the console to get to the two left hand vertical menu open/close. Where are the Market Open Times for the dashboard now which are essential , especially for crypto, given the graphs x axis time did not report time as set by helper and was different from log time? What was the benefit of this change?
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.
Matthew Martin
A few minor things I have noted:
1) Backtest results do not open. It seems like anything over about 500 days is the trigger for when it hangs indefinitely. If I keep QC and the terminal open for the entire backtest without the screen going blank, I can have the backtest results for tests greater than 500 days. If I log out or the computer sleeps, I cannot get the backtest results.
2) Please move active backtests to the top of the list instead of to the end. If I want to kill a backtest I have to scroll all the way to end of the page(s) in the dropdown. Also, logically, the rest of the tests are in reverse chronological order while these newest tests are at the end.
3) For multiple backtests the system performance seems significantly slower than before. My computer slows to a crawl. Since the computation is being down elsewhere, I would guess it is the graphics.
4) This is very minor, but is there any way to not make the first file in the project auto-open? If the first file is not my "main" file, it is always opened even when not needed. So it takes up tab space or I have to close it every time.
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 Root
Two small functionalities I would like to know about.

Python helper feature.
1. Python intellisense . (Like in C#)
2. When coding in the IDE.
3. In the IDE. Seems to work with the research environment.
Wordwrap feature
1. Wordwrap feature.
2. When coding in the IDE.
3. In the IDE. Would be nice for small screens.
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 Root
Also, when running multiple backtests, I have an issue pressing the next arrow through the row of backtests.
1. When running multiple backtests on the IDE dashboard in the Algorithm Lab, I am having issues cycling through the different backtests via the over button.
2. When cycling through multiple backtests.
3. IDE / Backtesting environment.
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.
Douglas Stridsberg
In addition to getting my additional chart as a narrow window, I now can't view it at all:
Is there a way to manually switch back to the old design until things are ironed out with the new one? I appreciate that it's good to switch things up and integrate the backtest and live views, but for those of us with real money on the line it's a little harrowing when things don't work. I'd rather be the last person to switch over to a new design than to have to worry whether my real money strategy is working as expected. I appreciate that there's a distinction between the terminal and the actual running algorithm and that it's likely the algorithm itself is running fine, but I hope you get my point regardless. We should really be given the option to opt in and out of the new design, or perhaps a limited set of users should be enrolled as beta testers before pushing such big changes live. From user feedback it seems enough things don't work for it to warrant a closed beta or opt-in approach.
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.
Jared Broad
shape. We remember what you have open too so it'll save your layout
preferences.
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.
Clayton Berry
I'll also add that we need the ability to hide the API explorer to recover screen real estate. What's also weird is that intellisense isn't mirroring the API explorer. Here's an example when looking at the Portfolio object...why doesn't intellisense match?
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!