Back

AverageFill Price is 0

orderTicketX=self.MarketOrder(self.ticker1 , self.xTradeQty)
orderTicketY=self.MarketOrder(self.ticker2 , self.yTradeQty)
avgXfillPrice=orderTicketX.AverageFillPrice
avgYfillPrice=orderTicketY.AverageFillPrice

In the above code, in backtesting, I am getting the average fill price as 0. Is there something that I am doing wrong?

 

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.


There's not enough information here to solve your problem.

Are you trading forex? or something denominated in less than 1 integer? like price could be 0.23333. the average of that is sometimes 0. Please post a full backtest or full snippet of code or a screenshot. 

0

I am trading MSFT and SPY. I have shared the backtest. Refer line 138-141 of code. I have tried logging in line 144, I have tried debugging. I always get 0 as avg fill price.

0


Any update on this? I have the same issue

1

Hi Javier and Amol,

The reason the AverageFillPrice is 0 is because according to these docs, this value is 0 if no fills have been processed for the order. This sometimes happens when an order is made outside of market hours, which we can see by the Market On Open orders in the backtest order logs.

To check if an OrderTicket has been filled, we can use the following line: 

if orderTicket.Status == OrderStatus.Filled:

Alternatively, if we wanted to get rid of the Market On Open orders, we can check for if the Market is open with self.IsMarketOpen(symbol).

Both changes can be seen in the attached backtest.

Best,
Shile Wen

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