Hi there.
How to ensure that my code doesn't use margin at all ?
In Initialization I use
self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage)
self.securities["symbol".SetLeverage(1)
self.x =(self.Portfolio.TotalPortfolioValue/10 )
self.x : is just a variable represent 1/10 of my all portfolio's cash value
in on data method I use
current_cash = self.Portfolio.CashBook[self.AccountCurrency].Amount
self.Portfolio.CashBook.Add(self.AccountCurrency, current_cash + 1, 1)
to add my profits to my portfolio's cash value
I'm not sure is this enough to ensure that my code doesn't use margin and use only Cash
Varad Kabade
Hi Gordon freeman,
We recommend setting the account type to cash:
Best,
Varad Kabade
XYZ2000
Thanks a lot ,it worked . But there is a problem
the back testing doesn't continue like before when I use minute resolution ,it only runs for 45 days and then the back testing stopped, I saw the console and there is a message that says
“Backtest Handled Error: Order Error: id: 6692, Insufficient buying power to complete order (Value:27445.6), Reason: The 'OCGN' security is not supported by this cash model. Currently only SecurityType.Crypto and SecurityType.Forex are supported”
so are there problems in my code , or the equity's data are not fully supported in Qunat connect ?
Varad Kabade
Hi Ахмед М. Ибраим,
To resolve the issue we recommend adding the following in Initialize :
and updating the brokerage model as:
Best,
Varad Kabade
Ахмед М. Ибраим
Hi Varad Kabade
Thanks a lot sir ,it worked fine
XYZ2000
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!