[R-SIG-Finance] Help request

me me at censix.com
Mon Apr 23 21:13:59 CEST 2012


Sameh

I am not the author of the IBrokers package, but I use it quite a bit.

Concerning the pop-up window asking you to allow connections to the
tws, I think there is a IB TWS setting in 'Configuration | API' that
allows you to disable this dialog.

Your code snippet looks ok. The issue seems to be that
you are not monitoring the replies that you will get from the IB TWS
once you have submitted your order, so your won't know if you had a
fill or if the order was canceled, etc.
For handling that you could use the "eWrapper" class (just
type ?eWrapper)

A more complex example (all source) is "qsiblive", which aims at
connecting R directly to the IB TWS/IB Gateway
and makes extensive use of the IBrokers package. You can download
"qsiblive" from my website http://censix.com 

Cheers

Soren

On Mon, 23 Apr 2012 19:21:13 +0200
Enrico Schumann <enricoschumann at yahoo.de> wrote:

> 
> Hi Sameh,
> 
> there are many people on this list who are much more knowledgable
> than I am -- and not just when it comes to the IBrokers package :-)
> (whose author/maintainer also is very active on this list).
> 
> I don't use IBrokers for trading, but the culprit seems to be reqIds;
> it does not seem to return an ID...
> 
> 
> Regards,
> Enrico
> 
> Am 23.04.2012 12:05, schrieb Sameh Rezeq:
> > Hello Enrico,
> >       I am interested in using R for IB interface. I am currently
> > running the demo version and wanted your insight regarding a
> > problem I am having. I have this small program that opens a TWS
> > connection with IB and tries to execute a simple order of BUY to
> > the contract "GBP.JPY". The connection gets established but the
> > order doesn't get executed. I tried to run a simple
> > "reqHistoricalData" command to make sure that the environment I am
> > operating under is functional and it was fine. Even though it
> > allows me to load only 2 days worth of data, which I think it might
> > be a limit for the demo users. I am attaching the program below, if
> > you will be kind to look at it and give me your feedback.
> >      Also, another small manner, when I execute the command "tws<-
> > twsconnect()", I get a pop-up window asking my permission to allows
> > the access. Do you think there is an automatic way to enable that
> > connection without having the pop-up window popping everytime I try
> > to make a connection with IB?
> >
> > Many thanks for your help!!
> > Sameh
> >
> >   #************************************************
> > library("IBrokers")
> >
> > contr<- twsCurrency(symbol = "GBP", currency = "JPY")
> > tws<- twsConnect() #sample(1e6,1))
> > #results<- reqHistoricalData(tws,
> > #                             Contract = contr,
> > #                             #endDateTime = "20120301 09:00:00",
> > #                             barSize = "5 mins",
> > #                             duration = "2 D",
> > #                             useRTH = 0,
> > #                             whatToShow = "MIDPOINT")
> >
> > idx<- reqIds(tws)
> >
> > twsO<-
> > twsOrder(idx,action="BUY",totalQuantity="18000",orderType="MKT",transmit=TRUE)
> >
> > twsPO<- placeOrder(tws,contr,twsO)
> >
> > twsDisconnect(tws)
> > #********************************************************
> >
> 



-- 

http://censix.com



More information about the R-SIG-Finance mailing list