Hi all,
My understanding of SetHoldings()/CalculateOrderQuantity() is that it will use the total portfolio value as its calculations. So if 90% of my portfolio are in existing holdings, and I wanted to SetHoldings(symbol, .2) I will not be able to fulfill the order because it is attempting to use 20% of my total portfolio.
Is there an equivalent method to using remaining buying power and percentages? In the above example, it was will 20% of the remaining unallocated 10% of my portfolio (2%)?
Rahul Chowdhury
Hey pcnpj,
You can access the remaining margin with
margin = self.Portolio.MarginRemaining
You can then distribute this margin amongst the securities you wish to buy.The buying power for a security is the leverage multiplied by the margin
buyingPower = security.Leverage * margin
You can then calculate the corresponding order size by dividing by the price of security
orderSize = buyingPower / price
Best
Rahul
Pcnpj
Thanks Rahul, I was going to go that route but was just curious if there was a method I couldn't find in documentation.
I will use this method. Thanks!
Pcnpj
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!