Search code examples
c#tws

how to get a open order or filled order's orderId with IB API?


I generated my trade system with IB API and C#.

I'm wondering whether is there a function to get the open/filled orders' orderId?


Solution

  • The IBApi.EClient.reqOpenOrders method allows to obtain all active orders submitted by the client application

     client.reqOpenOrders();
    

    or

      client.reqAllOpenOrders();
    

    results will be received in EWrapper with orderId and permId

    void openOrder(int orderId, Contract contract, Order order, OrderState orderState);
    

    in the end of execution you will hit void openOrderEnd(); method in your wrapper

    documentation: https://interactivebrokers.github.io/tws-api/open_orders.html