How to read ID's of open orders

Hello, I want to use IBcontroller to place trade stops, once per day, with EOD data from Norgate. I can send a new stop price with IBController but I dont' know how to modify yesterday's stop price because I don't have the EntryID of that order.

I know I can generate a new order and store the ID in a static var that supports the reboot of the computer but I prefer to read (if possible) the current ID of open positions, regardless they were opened manually or by IBcontroller.

Is this possible, I mean, to read the ID of an open order?

Thank you

Hi Armin,

Storing the orderid in a persistent static variable is probably the best way. But let's say the orderid was lost.

You have to take multiple steps to find it. You'll need to:

  1. Get the execution list.
  2. Examine every order in the list and see if the symbol matches the one that you care about.
  3. If the order's "Action" is what you care about (buy or sell), check the status of the order.
  4. If the "Status" is "PreSubmitted" or "Submitted" then the order is active in the market.

You'll also have to figure out how to handle multiple open orders, e.g. two stoploss orders with different number of shares and at different prices.

I hope this helps
-Peter

1 Like

It helps. Thank you.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.