Andrew,
Go here and download this: 1_Project_PlaceOrder.zip
To All:
I havnt spent much time at all on the placeOrder routine...that is
coming this week for me.
However here is my take on the whole affair after some quick study of
the methods.
The next valid Id call is made right after startup. If it is the
first time you have started IB for the day and have had no open
orders, the next valid id will be 0. If you have made orders the last
order id you placed will be incramented by 1...
That having been said..If you are making your first trade you can
assign anything you please as an order id...the key is to incrament
it each time a trade is made. If and when you logged off to go to
lunch for instance, then upon relogging, that is when the next valid
id comes into play. Of course your system could save the information
in the registry or whatnot and you more than likely could recall your
own last id and go from their...the bottom line is that the order
id's must ascend in relative value to one another...that is really
the crux of it...relogging in will fetch the next valid id..
All that having been said, let me share some code with you on how I
would handle incramenting the id and storing relevant order
information....
Assume your first chosen id is 3030. More on choosing id#'s later;
read footnote at bottom. Here is what happens. You place the order
and it is sent upstream to IB and they record your chosen order id.
If you relogged and captured the next valid id it would read
3031..but your not going to relog each time to fetch an id so you
have to handle the incramenting your self.
Now...you can incrament by whatever you choose...1, 5 10 etc...it is
a Long type value so you will be limited to a ceiling of
2,147,483,647...LOL shouldn't be a problem with whatever creative
method you choose to craft id's
So on to te crux of the matter....
First off I would create a module that tracks your order id and all
order information.
Second I would create a Form level sub to handle the Tws1.place order
call...
I would post the code but its easier to just download the project:
Scott
Owner TWS API Yahoo Discussion Forum