Hi everyone, I'm currently developing a C++ application for use with IB TWS API in C++ Builder IDE. I've imported the TWS ActiveX component and added to a form. Connecting via IB Gateway works flawlessly and I can receive account info. However, when using reqMktDataEx, nothing seems to happen, and the corresponding OntickPrice event never gets fired, even though I can see my even handling routine is associated with it. Pls see the code for data request below: ContractInfo->symbol = SysAllocString(L"ES"); ContractInfo->secType = SysAllocString(L"FUT"); ContractInfo->exchange = SysAllocString(L"GLOBEX"); ContractInfo->expiry = SysAllocString(L"201409"); ContractInfo->currency = SysAllocString(L"USD"); ContractInfo->includeExpired = true; Tws1->reqMktDataEx(0, ContractInfo, SysAllocString(L""), 0); Tws1->reqAccountUpdates(1, SysAllocString(L"DU126171")); Tws1->reqMktDepthEx(3, ContractInfo, 2); Any idea why some events get fired, and some don't? I'm using similar setup with Matlab and it works like a charm, hence my bewilderment...thanks in advance!
Without doublechecking the API documentation, I seem to remember some API method calls differed for C++ vs Java, and some that are available in one aren't in the other. I think matlab uses Java? Anyway, I could be completely wrong, but that may be a place to start.
Ok now I followed the tutorial on this page (http://stackoverflow.com/questions/11947586/exit-application-in-visual-c) in Visual C++ instead and had the same issue, events are still not triggered, any idea? The problem is obviously not related to the development tool...
Dumping the output from IB Gateway as well, anything out of the normal? SQ 12:09:08:773 JTS-ilhmdsDispatcher-138: QueryError QueryError Trading TWS session is connected from a different IP address, SQ 12:09:08:773 JTS-ilhmdsDispatcher-138: 0:62:71:1:0:4:2ET Sending error. SQ 12:09:08:788 JTS-ilhmdsDispatcher-138: 0:62:71:1:0:4:2ET 4;2;0;420;Invalid Real-time Query:Trading TWS session is connected from a different IP address SQ 12:09:08:788 JTS-ilhmdsDispatcher-138: 0:62:71:1:0:4:2ET Error sent. SQ 12:09:12:570 JTS-Cleaner-27: Cleaning maps SQ 12:10:12:580 JTS-Cleaner-27: Cleaning maps SQ 12:11:12:000 JTS-CCPDispatcher-29: Setting time offset to 4545 diff 133 SQ 12:11:12:719 JTS-Cleaner-27: Cleaning maps
Two possibilties: You are only allowed 5 (or so) API connections and you've exceeded this number. Maybe some are hanging up? You are only allowed to make so many requests/second in the TWS API. If you exceed this number it will get pissed off and boot you out. This is why you setup a data subscription once instead of pinging tws for a snapshot every pass of a while loop. Perhaps you are sending too many requests? I know I had this problem. Is anything working? Or just specific calls failing?
Yesterday the market data request with IB API has some problems. I couldn't get the open prices for several ETF at all. Don't know if it is related to your problems.
It's not clear from your code snippet when you request market data, etc. You should do that after receiving the nextValidId() event which signals successful connection. If you have any unhandled exceptions, all subscribed data streams are immediately stopped. You could be having an unhandled exception before the first tickPrice() event.
Normally I'm connected to IB Gateway on my remote trading server, while I do development on my local machine. All calls on the remote server works without a glitch. However, even after disconnecting from IB Gateway on the server, I'm still unable to retrieve market data on my local machine - connecting still works, so does retrieving account data - that's why I'm so puzzled...
I initiate the request via the command Tws1->reqMktDataEx(0, ContractInfo, SysAllocString(L""), 0); Then retrieving incoming data via regular OntickPrice event handler.
Ok, found the problem now: I was using the live IB account on the remote server and the corresponding paper trading account on the local machine - apparently both these have to reside on the same server (i.e. same IP address) otherwise either of them won't work. Annoying, but that's how it is...