Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My question is based on the detail from here:
http://www.interactivebrokers.com/en/?f=%2Fen%2Fsoftware%2Fibapi.php[^]

So using Java to Socket is a much better choice?
Posted

This is a misconception about how Excel's ActiveX interacts with the VBA.

See this[^] for a detailed explanation about that specific software and "losing" events.

As far as Java->Sockets, that's a matter of opinion and really lacks context in the web page you are referencing. From that page alone, I would not say its the "best" way of doing anything, it may be better in certain situations, but others it may not.
 
Share this answer
 
Their claim is probably based on poor code design then some inherent flaw in ActiveX. It did jump out to me that they called it "VB to ActiveX". If you are calling their API from vb via an ActiveX object then yes... I could see where events might get lost in a rapid-fire situation. But that type of setup was never designed for high performance. That is sort of like moaning that your Vespa scooter can't keep up on the freeway.

However, if you want to build you own app for their API, writing something in Java or .Net would be equally performant because you would make net socket calls in both cases. It just looks like there in no .net sample to look at.
 
Share this answer
 
Comments
[no name] 26-Jun-13 3:23am    
So far IB doesn't official support .net or .net socket, .net code still needs to use activeX to connect.
Jason Gleim 26-Jun-13 10:08am    
You're right... they make no mention of .Net. But considering they note VB & ActiveX as a way to connect to the service, I get the feeling they haven't really kept their public API up to date.

That being said, my point (that I didn't make clearly) is that if they support socket connections via java and c++, then a socket connection from .net will work just as well. There is no magic sauce to socket communication that makes it language-specific. They may not give you any help troubleshooting a problem if you are building something on .net, but there is no technical barrier preventing you from making the socket calls from a .net application. The Java samples should provide enough information that you could port them to .net.

Ultimately, it probably comes down to what you are most comfortable with. If you are a Java whiz, write it in Java. If you know .Net, you can probably use the Java samples as a basis and go from there creating something amazing. But I would avoid VB & ActiveX not just because they advise against it but because it is a bad choice for a custom app. Especially if you are micro-trading with your solution.... you need responsiveness and sockets will give you the best performance.
[no name] 26-Jun-13 12:35pm    
your answer is really good.
[no name] 27-Jun-13 5:30am    
If I use .net C# with activex, while I do analysis with 1 second to 5 seconds data, would that be a problem? What intensive level would start to see activex has some problem?
Jason Gleim 27-Jun-13 9:49am    
That is nearly impossible to predict. It depends on so much... how fast you process events, the specs of the machine it is running on, what else may be running, etc. There are some things you can do to help avoid problems such as making sure your loop which receives the data is fast and tight. So maybe all you do in it is grab the data and push it onto a queue for later processing by a background thread. That way the data exchange is as fast as possible and you push the heavy lifting out of the data exchange.

The same sort of principle applies for any high-data rate application. If there is a risk that it will take longer to process the data than the interval in which the data could arrive, then you have to decouple the process of getting the data (making it high priority) from processing the data (making it low priority). For example, if it took two seconds to process a data packet and the packets arrive every second, then you need two processing threads to handle the data as it arrives. Anything less and your queue would eventually overflow and you would lose data. If setup properly, the issue then boils down to an issue of managing the queue.

If your data rate became too much for regular threads on a multicore processor, then shifting data processing over to a GPU may provide a solution. But at your proposed data rate that doesn't seem like something you would need to do. (Unless you are doing something like a FFT on the data.)

Of course, the complexity of the solution increases as the demand for speed increases. I can only advise you on what the options are, you have to make the evaluation for your project. I do think that if you aren't doing a bunch of heavy processing on a chunk of data, a simple mechanism to receive the data via ActiveX, push it onto a queue, then have a background worker pop the data off the queue and process it would probably work very well for your app and easily handle your proposed data rate. If you are concerned, you can profile your app while it is running and get an idea of actual execution times for each part as it runs.

Hope that helps!
Jason

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900