IB API: Request position per instrument

Discussion in 'Programming' started by TraDaToR, Jan 19, 2013.

  1. TraDaToR



    I don't remember if I already asked this question before, but is there a way to request current positions in the portfolio for a given instrument? I am using excel with DDE links but I guess it must be the same problem with other languages...

    If you use the sample spreadsheet for automation, you must download the whole portfolio of your account, find the instrument in the list, check its position and then apply your system. I would like to know if there is a way to directly check your position on CL futures for example.

    I use my IB account for lots of stuff , not just systems, and I find it complicated when you have numerous positions in your portfolio.

    If somebody knows something I don't.

    Thanks a lot.

  2. what's wrong with requesting the portfolio and then finding the instrument and its associated position?
  3. TraDaToR


    Not much, just simpler to program and it gets really messy when you have traded 10s of instruments in the day, they don't disappear even if you are flat, so you have to check 10s of instruments, and I am not even talking about trading different expiries or spreads of a given symbol...It would be just better to ask the system "OK, so what is my position on corn Mar-May-July butterfly now?".
  4. vicirek


    This is more for ActiveX than DDE but both have very similar functionality.

    I just checked IB API guide and noted that you can request execution report and use specify filter with several different options including symbol in ActiveX. Account update does not have such flexibility.

    I do not use any of those because my real time application tracks current info from order status event (not easy to use because of multiple updates with the same data) and anything beyond that can be accessed in TWS so I do not duplicate this functionality. In addition both execution report and account update are not immediate and update periodically. In contrast order status updates immediately.

    IB API assumes that programmer will do most of the work designing their custom application and does not give you higher level methods to deal with customizations. It is understandable because they do not know how one wants to implement their API.
  5. TraDaToR


    That's what I was doing previously, but when you try to trade high volume/small average trade strategies with lots of execs, it's hard to get the position count right with DDE links...