I tried to debug the script with "print" statements, couldnt find any issue but still nothing was printed.. appending my code for reference please, i have checked if the API was connected using app.run(), it somehow still seem stuck
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
from ibapi.order import Order
from ibapi.common import *
from ibapi.execution import Execution
from ibapi.order_state import OrderState
import threading
import time
class MyWrapper(EWrapper):
def __init__(self):
self.next_order_id = None
self.order_ids = set()
self.executions = []
self.orders = {}
def nextValidId(self, orderId: int):
super().nextValidId(orderId)
print(f"Received next valid order ID: {orderId}")
self.next_order_id = orderId
def orderStatus(self, orderId:OrderId , status:str, filled:float, remaining:float, avgFillPrice:float, permId:int, parentId:int, lastFillPrice:float, clientId:int, whyHeld:str, mktCapPrice: float):
super().orderStatus(orderId, status, filled, remaining, avgFillPrice, permId, parentId, lastFillPrice, clientId, whyHeld, mktCapPrice)
order = self.orders[orderId]
order.filled = filled
order.remaining = remaining
order.avgFillPrice = avgFillPrice
order.status = status
print(f"Order status update: {status}")
if status == "Filled":
order.completed = True
def openOrder(self, orderId: int, contract: Contract, order: Order, orderState: OrderState):
super().openOrder(orderId, contract, order, orderState)
self.order_ids.add(orderId)
self.orders[orderId] = order
print(f"Received order {orderId} for contract {contract.symbol} with state {orderState.status}")