IB API Order ID question

Discussion in 'Automated Trading' started by bidask, Jul 3, 2008.

  1. edbar

    edbar

    Stevegee is right.

    Right after you connect with the API, immediately call nextValidId and save the number it gives you. Then, whenever you need an id (requesting quotes or placing orders), just increment the number by 1 (or by anything you want). As long as the id you use is greater than the last one used, you will be fine.

    Ed
     
    #11     Jul 4, 2008
    Risk619 likes this.
  2. Simple question,

    Using the Excel DDE, what is the syntax to return the porftolio's values (Symbol, Shares, Avg Price, etc.)? I tried the following:

    =test123|acct!id0?localsymbol?

    But it returned 0 for all id values, I am sending orders automatically through the orders spreadsheet...
     
    #12     Jul 14, 2008
  3. sprstpd

    sprstpd

    I believe when you connect to the API you specify a client ID. Make sure the client ID is not 0 (i.e., 1) and then you will never see manual orders via the API. If you want the API to be able to track and modify manual orders, well then I have never heard of a guaranteed solution for your problem.
     
    #13     Jul 14, 2008
  4. Client ID is in there to send orders and the sample portfolio page works when I subscribe its just that its unstable and needs to be restarted at times.

    I think it may be due to the worksheet.change event that controls it but I'm not sure. Either way I need a work around and the DDE link was one method.

    I imagine it needs the id of the position but I can't figure out which method calls the id number....
     
    #14     Jul 14, 2008
  5. Yep it was simple, no '?' on the end..

    "=test123|acct?id1?symbol"

    works......kinda, still to be seen how stable this it is.

    Where you cycle through the id #'s 1...n
     
    #15     Jul 15, 2008