[R-SIG-Finance] Help request

Enrico Schumann enricoschumann at yahoo.de
Mon Apr 23 19:21:13 CEST 2012


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)
> #********************************************************
>

-- 
Enrico Schumann
Lucerne, Switzerland
http://nmof.net



More information about the R-SIG-Finance mailing list