I don't mean setting the leverage for a Universe I'm working with, but if I'm adding securities manually for example through self.AddEquity(), and I add let's say 10 securities through this, how do I make it so the algo works with just x1 leverage by default for all the securities? Or is the only way to manually set the leverage for each security that I'm adding?
By default the leverage is set to 2 for the IBKR model, how do I set the default to 1 instead?
Rahul Chowdhury
Hey Vincent,
We can use a custom security initializer to automatically set the leverage for any securities we add to our universe.
# In main.py def CustomSecurityInitializer(self, security): security.SetLeverage(1)
Then in Initialize we can set our security initializer
self.SetSecurityInitializer(self.CustomSecurityInitializer)
Learn more about security initializers in the documentation.
Best
Rahul
Frank Schikarski
Hi guys,
building on the helpful comment on leverage from Rahul Chowdhury, please find here an option for (a) using leverage on security level together with (b) a margin type brokerage model.
According to the documentation on key concepts of universe selection, the SetSecurityInitializer method overwrites the default security initializer including the selected brokerage model, and we can use our brokerage model if we extend upon the default security initializer instead of overwriting it.
Any comments welcome ;)
Best
Frank
Vncne
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!