Back

During backtesting, when is an order filled?

TLDR: Market orders are filled even if there is nothing in the order book. Should this be the correct behaviour?

I am testing an options strategy that makes Market orders. At the time I make the market order I also log the current Bid/Ask prices. It seems the market order is marked as filled at the current best Ask price, even if there isn't any Bids. This seems very unrealistic that we assume we immedately get filled at the current best Ask, even if there is no bid.

Example from my logs:

2018-02-12 09:31:00 : Bid/Ask 0.0/2.9
2018-02-12 09:31:00 : Time: 2/12/2018 2:31:00 PM OrderID: 5 Symbol: GOOG 180216C01197500 Status: Submitted
2018-02-12 09:31:00 : Time: 2/12/2018 2:31:00 PM OrderID: 5 Symbol: GOOG 180216C01197500 Status: Filled Quantity: -1 FillPrice: 2.9 USD OrderFee: 1 USD

 

Now, if there is a bid price, then the market order uses the best bid as the fill price, which sounds realistic.

So I'm wondering. Is this the expected behaviour? If so, should this be changed?

For completeness, here is also an extract from my logs when there is a bid price, in which case the market order is filled at the bid:

2018-02-12 09:31:00 : Bid/Ask 0.05/1.0
2018-02-12 09:31:00 : Time: 2/12/2018 2:31:00 PM OrderID: 6 Symbol: GOOG 180216P00900000 Status: Submitted
2018-02-12 09:31:00 : Time: 2/12/2018 2:31:00 PM OrderID: 6 Symbol: GOOG 180216P00900000 Status: Filled Quantity: -1 FillPrice: 0.05 USD OrderFee: 1 USD

 

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.


Hi MateHegedus,

Thank you for sharing the logs. It does seem very strange to see Bid at 0.0 as this shouldn’t happen. In order to assist you with the issue further, we need to be able to reproduce your results, so could you please share your algorithm?

Thanks for your support!

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