Hello,
?
I have an issue handling the partial fills orders, in my code, I need to make sure that all partial orders are executed to process the next steps, I use the remaining function from trade object to check if the remaining shares is equal to 0 or not, below is my code, the issue here is that it give always remaining == 0 even there are some remaining shares.
?
I use this event:
self.ib_client.execDetailsEvent += self.on_exec_details`
?
?
?
` def on_exec_details(self, trade, fill):
? ? ? ? symbol = trade.contract.symbol
? ? ? ? if symbol in self.positions:
? ? ? ? ? ? trade_type = trade.order.orderType
? ? ? ? ? ? side = fill.execution.side
? ? ? ? ? ? order_id = trade.order.orderId
? ? ? ? ? ? shares = fill.execution.shares
? ? ? ? ? ? while not trade.isDone():
? ? ? ? ? ? ? ? logger.info(f"{symbol} : Trade type: {trade_type}/{side}, Trade Status {trade.orderStatus.status},"
? ? ? ? ? ? ? ? ? ? ? ? ? ? f"remaining shares: {trade.orderStatus.remaining}")
? ? ? ? ? ? ? ? self.ib_client.sleep(1)
? ? ? ? ? ? logger.info(
? ? ? ? ? ? ? ? f"Execution of {trade_type} order for {symbol}, side = {side}, "
? ? ? ? ? ? ? ? f"shares = {shares}, order_id = {order_id}, Trade Status = {trade.orderStatus.status}"
? ? ? ? ? ? ? ? f"remaining shares: {trade.orderStatus.remaining}"
? ? ? ? ? ? )
? ? ? ? ? ? self.ib_client.sleep(1)
? ? ? ? ? ? if trade.remaining() != 0:
? ? ? ? ? ? ? ? return
?
Could you please help me understand why this is not working properly?