When an order status is PartialFilled.. eg. ordered 100 but only filled 70. How can I obtain the amount filled?
I understand, if I canceled the order, I keep the 70 that was filled. Due to lag, additional 10 may be filled before the order is canceled. Now I have 80. How do can I know the filled quantity now is 80? Can I obtain this using the order ticket? I assume the order ticket is still valid even after the order is canceled.
Rahul Chowdhury
Hi Hew Kok Wooi,
There are two ways to check the fill quantity for an order.
1. You can access it through the order ticket. OrderTicket contains the field QuantityFilled, which returns the total quantity filled for this ticket. If no fills have been processed then this will return a value of zero. This means ticket.QuantityFilled will return the amount filled so far for that order.
2. You can use the OnOrderEvent method, which fires every time there is an order event, including fill or partial fill events. The OrderEvent object contains information about how much was filled.
def OnOrderEvent(self, orderevent): if orderevent.Status == OrderStatus.PartiallyFilled: symbol = orderevent.Symbol fill = orderevent.FillQuantity
Best
Rahul
Hew Kok Wooi
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!