Back

Tiingo - Insufficient Buying Power

I keep getting the error messages below when running this algorithm.   Can someone please advise regarding what I need to do to address this error?   I'm still learning Python so if someone could provide the actual code or a corrected algorithm it would be appreciated. Thanks,Troy  
260 | 12:20:33:
Backtest Handled Error: Order Error: id: 53, Insufficient buying power to complete order (Value:1112095.7532), Reason: Id: 53, Initial Margin: 1011014.9642465454545454545455, Free Margin: 103632.6538046989706545454545


261 | 12:20:33:


Your algorithm messaging has been rate limited to prevent browser flooding

 

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 Troy,

Tiingo news data can be emitted when the market is closed. Your algorithm is taking the insights from these overnight emissions and creating market on open orders. If the gap between the market close price and market open price is large, you may get an insufficient margin error.

One way to work around this error is to not emit any insights during market close.

You can accomplish this by returning at the beginning of AlphaModel.Update if the market is closed.

if not algorithm.IsMarketOpen("SPY"):
return insights

You can also consolidate all insights generated overnight in a class variable and then emit them at market open. However keep in mind that QC's PortfolioConstructionModels only take into account the latest insight when creating portfolio targets.

If you want to take into consideration all of the overnight news data when emitting an insight at market open. You could store all the overnight news data, calculate a sentiment, and then emit one insight at market open.

I modified your algorithm to store all overnight insights and emit them at market open, which effectively trades on the latest overnight insight for each symbol.

Best
Rahul

2

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 appreciate the detailed explanation and information.  This is exactly what I was looking for.

Thanks again,

Troy

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