Back

Insufficient buying power

Very often (cca 20% of time) I am getting following error in my backtesting:

Backtest Handled Error: Order Error: id: 11, Insufficient buying power to complete order (Value:24955.9785), Reason: Id: 11, Initial Margin: 12478.9892365, Free Margin: 154.669432942

Derek Melchin proposed the lower percentage in self.SetHoldings function and using cash buffers, that is using self.Settings.FreePortfolioValuePercentage function.

I implemented both things using:

self.Settings.FreePortfolioValuePercentage = 0.5

self.SetHoldings("SPY", .5)

but it didn't help. I am still getting trhe same error (not as often as before, but still).

Attached you can find the whole code of the backtest. It's relatively long, but most important are the lines of code above.

I can try with even lower percentage values and higher cash bufferrs, but that changes my strategy a lot since I invest only small fraction of available cash when I want to invest almost everything (say 90%).

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.


Only 2 weeks old in Quantconnect so take it with a pinch of salt., as I can see you are trying to execute based on minute resolution.

So you can at a time only place 2 orders (but I read there are some buffer kept so not sure if the second trade will be executed )

I am not sure when the prediction is 1 and -1 but maybe you can

  • check first that there are no active trades going on from Portfolio and setHoldings only if there are none
  • Or you can only use 10% (0.1) of the equity to place orders, so that at least you can take 9-10 orders
May be someone else may have better answers.
0

Hi Mislav; out of respect for the community please do not double post. Price and portfolio buying power discipline is an important part of designing an algorithm. 

@Ray "So you can at a time only place 2 orders" - This is not true. You can place as many orders as the brokerage will allow for your account type and buying power. For a margin account this is generally up to 2x buying power.

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.


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