Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Re: ReqOpenOrders and next order id
bee_jay_61
No. You can call reqOpenOrders only once. Than you will got all open
toggle quoted message
Show quoted text
orders. And I think this is ok. I do the following in my Delphi program: I have a List (TList object) which can stores all order data and some additional information (ex. my internal order status, order id). At the startup of my program and after connected to the TWS, this List will be cleared and ReqOpenOrdeed is called. If there are open orders, than the data of all open orders are added to the List in OnOpenOrder event. When I call PlaceOrder than the event OnOrderPlaced is fired if there were no problems with sending the data to the TWS. In OnOrderPlaced I add the order data of the placed order to the List. Of course I could do this before calling PlaceOrder but if there are problems than I have to delete the data. OnOrderPlaced? The ActiveX does not give me the functionality I want so I have rewritten the ActiveX. As I am a Delphi programmer I put all properties, methods and events from the ActiveX into a VCL and than extended the VCL with every function I need like OnOrderPlaced, OnOrderFilled, OnConnectionOpened, OnOrderSubmitted etc. When OnOrderCancelled, OnOrderSubmitted or something like this is fired than I will search for the order id the my List and update the order data and my internal order status. If there are any problems with the connection to the TWS and I have to close the TWS than my program waits until the TWS is restarted. My program will notify when the TWS restarts. Than it searches the Login-Window and logs in automaticly. Than it waits until the Login- Process window disappears and tries to connect to the TWS automaticly. I can activate and deactivate this re-autoconnect feature in my programs option dialog window. After successfully connected the OnConnectionOpend event is fired. There I clear the List and call ReqOpenOrders. This will fire the OnOpenOrders event, where the List will be filled with all open orders. And so on. This works really fine for me. Another think often read: problems with the order id and how to find out the id for the next order or what?s the best way to calculate the order id. That?s what I do: Normally, my program starts the TWS. I only start the TWS manually if there a problems. Before my program starts the TWS I set the entry "DDEId" to 1. You will find this entry in the USER.INI in the folder "C:\IB TWS\<your crypted username>\" - if your path is C:\IB TWS\ ;-) The first time the OnNextValidId event is fired I allways receive 2. But I never use this value. I just use the window API function GetTickCount. I never had this error message with "doublicate error id" or something like this. The GetTickCount function retrieves the number of milliseconds that have elapsed since Windows was started. But be carefull: the time will wrap around to zero if Windows is run continuously for 49.7 days ;-) The only problem I had for a while was how to find out the folder- name where the file USER.INI is saved. If there is only one user which uses your program than you can take the folder name (with the crypted user name) into your program or INI file. But if there are more users and you don?t know the crypted users name it is a bit difficult to find the desired folder name. In my programs options dialog you can specify the user name and I have written a routine to crypt the user name exactly the way the TWS does. So I can find easyly the users USER.INI. If somebody is interessed in this routine you can mail me. Hope you could understand MY english ;-) --- In twsapi@y..., "grozzie2" <grozzie2@y...> wrote:
Build 769 or 770 for that.Have you got reqOpenOrders to work on demand rather |
to navigate to use esc to dismiss