I want to implement my models in R and trade according to them with my IB account. Now I am wondering, how I should solve this problem? Do I need to program with C an access (https://www.interactivebrokers.com/en/?f=%2Fen%2Fsoftware%2Fibapi.php) or is there a solution, where I only need R and IB?

How do profeesional people solve this issue? And what about the IBrokers package in R, is it still valid? It seems to me a bit outdated, is there a better package? Thanks for sharing your wisdom in advance!

  • $\begingroup$ If you're comfortable integrating R and Java, the Java API is very easy. I used that API with java-websocket to make a custom position tracking system through a browser very quickly. $\endgroup$ – user6500 Dec 23 '13 at 5:53
  • $\begingroup$ @quantycuenta Thanks a lot, but what does "through a browser" mean? I mean if I have R some Java program (netbeans or so) and the TWS system of IB with the Java API, is that all I need? Is this the "best" / most efficient way to do this? $\endgroup$ – Jen Bohold Dec 23 '13 at 9:10
  • $\begingroup$ This is a beginners question I hope you don't mind: How does this work and how do they connect? I call in my Java environment some R code which does fancy calculations and gives me a value. Then depending on that value I sell or buy a certain option. So still in my Java environment I write the command to buy/sell an option. When running this code the command is sent to the Java API which further sends it to the TWS system? Or is it directly out of my Java environment send to the TWS system? Why do I need the additonal Java API? What is the difference from TWS system to using the IB Gateway? $\endgroup$ – Jen Bohold Dec 23 '13 at 9:14
  • $\begingroup$ I was just trying to explain how easy it was to program with the IB java wrapper with the websockets example. Actually, after reading your second comment, and assuming you're ok with jquery/HTML5, that would be the way to go on the frontend, imo, and just trade through TWS. Few hundred lines of code for me. json2html really helps. I can give you a general structure for the ib-websocket fusion if you like. As for the R-java fusion, I can only superficially help: R is interpreted (if memory serves), so java should always outrun it. $\endgroup$ – user6500 Dec 23 '13 at 9:42
  • $\begingroup$ You can get them talking with this stackoverflow.com/questions/7451716/java-r-integration. TWS is the trade platform. The IB gateway is merely an authentication portal for your custom app. I prefer not to buy and sell through a custom app myself. I'm a one man show and don't have an expert looking over my shoulder to prevent me from destroying myself with code. I track with my custom app, and it's easy to see if something's going wrong with that. Open another question so all can benefit on the java api reporting question, so all can benefit, if you please, and i'll answer. $\endgroup$ – user6500 Dec 23 '13 at 9:46

You'll want the ibrokers package, its very good and built on the c++ api.

Also check out quantmod, performanceanalytics, and highfrequency package.

And a comprehensive list, http://cran.r-project.org/web/views/Finance.html


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.