Hi guys, i'm having problems writing code in C# that sends multiple orders to TWS. Sending 1 order works, so the issue might to be with the next order ID number. Also the same code (for multiple orders) works in IB Demo mode.....Appreciate any help!
Are you checking error messages? With regards to order ID you receive next valid order ID from TWS and then you increment it for consecutive orders. If it works in Demo but not real account then the issue might be with account permissions, account type etc.
i do all that - receive the valid ID from TWS and then increment it for the orders that follow but whats strange is that i'm able to send 1 single order via API, so shouldnt it mean that my acct settings are fine? or there's a setting in TWS that prevents sending more than 1 order at once? could it be that the TWS version that i'm using (946.2h July 31, 2014) has bugs? where can i get an older TWS ver.? Thanks
If there is a bug it is more likely in your program so you have to start there. Assuming that your place order function returns meaning that formatted order string has been sent to TWS it will trigger response/s from TWS. In case of error/information message you can read it in error message event. Otherwise order status event will show some progress or lack of it so this is another place to check. In addition you can set more detailed log level and see what TWS is doing. Those three are provided to you by IB. Any additional debug info you would have to set up yourself. There is a limit on number of messages per second being passed to TWS and you have to watch for it if you sending many orders in one short burst. Remember that in real account there are other checks like margin, price not exceeding certain limits away from market etc.
To get the orderID you have 2 ways to do it: 1. Use the NextOrderID function from IB Server, but there might be some small delays in the reply, so make sure your code catch that by "waiting" for the nextOrderID before going to the next trade 2. You could assign and manage locally your own OrderID, so you don't have to wait for IB server replies for NextOrderID, and then send your batch orders with a locally incremented OrderID. Make sure it's above 1 at a starting value or it doesn't conflict with existing orderID that you previously issued with NextOrderID also make sure that the Order and Contract objects have been "updated" with each new trade, might sound silly, but you never know