A method for remaining buying power, equivalent to Set Holdings?

Back

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%)?

 

Update Backtest







 
0

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.


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

1

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.


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!

0

Update Backtest





0

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.


Loading...

This discussion is closed