Hi,
I've been getting the error below when submitting market orders during backtesting. Limit orders seem to work fine. Syntax is very straightforward: self.market_order(symbol1, quantity1). Orders are submitted 15 mins before market close.
Backtest Handled Error: Order Error: id: 5, Transaction model failed to fill for order type: Market with error: unsupported operand type(s) for *: 'float' and 'MarketOrder'
Anyone encountered this before? Don't know where the ‘float’ comes from. I've made sure quantity1 is an integer.
Mia Alissi
How to use this to debug your issue:
debug_market_order_statemethod and the assignment ofself._original_market_order_refinto yourinitialize()into your own algorithm.self.debug_market_order_state(symbol1, quantity1)immediately before everyself.market_order(...)call.Bonus manual checklist:
market_order = ...,def market_order(, orMarketOrder(used on the right side of a multiplication (*) operator.self.market_order(...)and then performs arithmetic on it.MarketOrderobject instead of a numeric fill quantity or price.This methodical approach should help you pin down what's hijacking the market order flow!
Sources: docs writing algorithms trading and orders order errors, docs writing algorithms live trading notifications, docs writing algorithms live trading brokerages, Stop Market Orders - QuantConnect.com, Key Concepts - QuantConnect.com
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.
Dat En
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!