Search code examples
interactive-brokerstws

IB TWS API c# get LmtPrice of Order object


Have Order Id, need code sample how to read order's limit price. Documentation here does not contain any easy-to-go code snippet.


Solution

  • The columns for the DataGridView called 'liveOrdersGrid' are added in the designer of IBSampleApp.cs. The col contents are populated by the class 'OrderManager.cs', inside the method PopulateOrderRow(int rowIndex, OpenOrderMessage orderMessage).

    To add a new col containing LMTPrice add a new line such as; (You need to use the designer and add a 11th col first)

    private void PopulateOrderRow(int rowIndex, OpenOrderMessage orderMessage)
        {
            liveOrdersGrid[0, rowIndex].Value = Util.IntMaxString(orderMessage.Order.PermId);
            liveOrdersGrid[1, rowIndex].Value = Util.IntMaxString(orderMessage.Order.ClientId);
            liveOrdersGrid[2, rowIndex].Value = Util.IntMaxString(orderMessage.Order.OrderId);
            liveOrdersGrid[3, rowIndex].Value = orderMessage.Order.Account;
            liveOrdersGrid[4, rowIndex].Value = orderMessage.Order.ModelCode;
            liveOrdersGrid[5, rowIndex].Value = orderMessage.Order.Action;
            liveOrdersGrid[6, rowIndex].Value = Util.DecimalMaxString(orderMessage.Order.TotalQuantity);
            liveOrdersGrid[7, rowIndex].Value = orderMessage.Contract.Symbol+" "+orderMessage.Contract.SecType+" "+orderMessage.Contract.Exchange;
            liveOrdersGrid[8, rowIndex].Value = orderMessage.OrderState.Status;
            liveOrdersGrid[9, rowIndex].Value = Util.DoubleMaxString(orderMessage.Order.CashQty);
            // New col at end for LMT Price
            liveOrdersGrid[10, rowIndex].Value = orderMessage.Order.LmtPrice;
        }
    

    However before getting too far make sure you double click the line, it opens up a order modify dialog. enter image description here