Back

How do I check buying power?

How do i check buying power? And gracefully avoid: Runtime Error
Order Error: id: 81: Insufficient buying power to complete order
Update Backtest








Hey Joshua - buying power depends on your holdings of a certain asset, and the direction you want to trade. E.g. if I'm long 100 I can feasibly go -200, vs, if I was already short -100 I might not have any room at all.
Portfolio.GetBuyingPower(string symbol, OrderDirection direction = OrderDirection.Hold)

This code is calculated here on GitHub.

When you place a trade (synchronous trade) it instantly updates the cash position remaining on your account. The raw buying power for a new asset which you have no holdings would be cash * leverage.
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.


I'm trying to output the value returned by Portfolio.GetBuyingPower(), but I'm getting a build error. here's the code and the error. Do you have any ideas on how to resolve this?

public void OnData(TradeBars data) {
...
Debug(Time.ToShortDateString() + " Buying Power = " + Portfolio.GetBuyingPower("SPY", OrderDirection.Buy));
...
}



153 | 21:40:40:
Build Error: File: Main.cs Line:48 Column:68 - 'SecurityPortfolioManager' does not contain a definition for 'GetBuyingPower' and no extension method 'GetBuyingPower' accepting a first argument of type 'SecurityPortfolioManager' could be found (are you missing a using directive or an assembly reference?)
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