Anyone got experience with the Java API of Interactive Brokers? I've started using it recently and either I don't know how to use it right it or it's very, very buggy. I'm trying to get an option chain and I'm only getting partial data. I see in the TWS log that it sends me a lot of contract details but in my application I'm only getting a few of them. It's like their API is losing messages. I've resorted to horrible hacks such as disassembling their code from the API JAR and modifying it. Increasing the socket buffer from 8Kb to 64Kb seems to have solved the problem and again points in the direction that they provide a poor quality solution. It's like they don't do code reviews or at least test their stuff... I'd contact their support and point out the issues but I've heard horrifying stories of having to deal with them. Could they be true?
I reliably use the C++ API to get the option chain all the time. (Under the hood it's the same messaging protocol.) How do you know you're not getting all the data? Did you put prints in the contractDetails and contractDetailsEnd callback functions?
Well, for starters I didn't get the contractDetailsEnd callback. Then, after several restarts, sometimes I got it, sometimes not. Finally, I got fed of it and dissasembled the JAR, placed some debug breakpoints and did some step-trough. At this point, depending on how long I'm spending in some read message function, I'm only getting some 5-10 options in the callback, instead of some 200 as there should be. From the way it looks, I can tell that the message reading function is c*ap. Eventually I might spend some time to understand and correct it but for now I've tried a lucky shot and increased the buffer. So far it worked but I don't like the solution as it's brittle. If I wrote that kind of code at work, it'd be my ass I wonder if I can contact their dev team and point out the issues / solution. Or just leave it be and use it myself. Problem is, when they'll update the API / JAR, I'll have to start fixing their shit all over again.
Still, did you put prints in contractDetails? Maybe you're getting all the results you asked for but contractDetailsEnd is having issues. In all honesty I only get the option when my application first starts and before I do anything else with the API. Maybe you have another thread interfering?
Yes, I'm processing the options in contractDetails. Problem is I *should* get a contractDetailsEnd anyways, that's in the API specifications. For now it seems solved, if there are problems I'll enlarge the buffer even more, there's plenty of RAM nowadays.
I use the Java API from IB, and I never have problems getting contractDetailsEnd(). Suggestion to narrow down if the problem is with TWS/IB or not: Try to comment out all the code in all the EWrapper methods, except for putting one single print in the contractDetailsEnd(). If you try this, and find that the contractDetailsEnd() is still not being called, would you mind posting a followup here with the fields you are filling out in the Contract class parameter you are passing to reqContractDetails() and I'll give it a try later this evening. I think it is probably more likely you have some kind of data synchronization issue from multiple threads...
Fwiw I've had a similar problem with getting: m_symbol: NG, m_tradingClass: LNE, m_exchange:NYMEX, m_secType: FOP, m_currency: USD I request about 60(?) variations of those attributes accross mutiple asset classes and exchanges and only this one fails to trigger contractDetailsEnd. I randomise the order in which the requests are made. I haven't exhaustively checked if all the contract details are actually returned but it does give about 7,000 contract details for that request alone (a long time) before I let it timeout. I am however using the IbPy implementation of the API interface, but perhaps it's a broadly similar issue.
Usually when you hit some kind of limitation on the data requested from TWS API, you will receive an error() message of some type called in your EWrapper. Maybe check for those too?
@Aquarians I am using the IB java API. I have not encountered the problem you describe. What makes you so certain that the problem must be in their software and not in your implementation? Their API already exists for quite a number of years and you are most likely not the first person to use it for option chains. Have you tried to use a print statement in the overridden method that gives you all contract information as and when it comes in?