[R-SIG-Finance] ibrokers

Jeff Ryan jeff.a.ryan at gmail.com
Sun Nov 28 16:09:12 CET 2010


Hi Stephen,

I'm not subscribed to ASX data, so I can't readily replicate.  That
said, I think you are just missing the currency="AUD" (defaults to USD
... maybe I will make this a global option)

> reqContractDetails(ibg, twsEquity("CBA", exch='ASX', currency="AUD"))
[[1]]
List of 18
 $ version       : chr "6"
 $ contract      :List of 16
  ..$ conId          : chr "4036818"
  ..$ symbol         : chr "CBA"
  ..$ sectype        : chr "STK"
  ..$ exch           : chr "ASX"
  ..$ primary        : chr "ASX"
  ..$ expiry         : chr ""
  ..$ strike         : chr "0.0"
  ..$ currency       : chr "AUD"
  ..$ right          : chr ""
  ..$ local          : chr "CBA"
  ..$ multiplier     : chr ""
  ..$ combo_legs_desc: chr ""
  ..$ comboleg       : chr ""
  ..$ include_expired: chr ""
  ..$ secIdType      : chr ""
  ..$ secId          : chr ""
  ..- attr(*, "class")= chr "twsContract"
 $ marketName    : chr "CBA"
 $ tradingClass  : chr "CBA"
 $ conId         : chr "4036818"
 $ minTick       : chr "0.0010"
 $ orderTypes    : chr [1:34] "ACTIVETIM" "ADJUST" "ALERT" "ALLOC" ...
 $ validExchanges: chr [1:2] "ASX" "MIBSX"
 $ priceMagnifier: chr "1"
 $ underConId    : chr "0"
 $ longName      : chr "COMMONWEALTH BANK OF AUSTRAL"
 $ contractMonth : chr ""
 $ industry      : chr "Financial"
 $ category      : chr "Banks"
 $ subcategory   : chr "Commer Banks Non-US"
 $ timeZoneId    : chr "AET"
 $ tradingHours  : chr "20101129:1000-1611;20101130:1000-1611"
 $ liquidHours   : chr "20101129:1000-1611;20101130:1000-1611"

HTH,
Jeff

On Sat, Nov 27, 2010 at 11:57 PM, Stephen Choularton
<stephen at organicfoodmarkets.com.au> wrote:
> I'm having a lot of trouble geting to grips with this. Nothing unusual but
> ...
>
> I am trying the five main functions from Jeffrey's  paper (IBrokers-
> Interactive Brokers and R)
>
>
>> library(IBrokers)
> Loading required package: xts
> Loading required package: zoo
>> tws <- twsConnect()
>> tws
> <twsConnection,1 @ 20101128 16:07:16 Eastern Standard Time (New South
> Wales), nextId=1>
>> reqMktData(tws, twsEquity("CBA", exch='ASX'))
> TWS Message: 2 -1 2104 Market data farm connection is OK:cashfarm
> TWS Message: 2 -1 2104 Market data farm connection is OK:aufarm
> TWS Message: 2 -1 2104 Market data farm connection is OK:usfarm
> <20101128 16:09:56.557000> id=1 symbol=CBA highPrice: 0
> <20101128 16:09:56.620000> id=1 symbol=CBA lowPrice: 0
> <20101128 16:09:57.073000> id=1 symbol=CBA bidPrice: -1.0  bidSize: 0
> <20101128 16:09:57.073000> id=1 symbol=CBA askPrice: -1.0  askSize: 0
> <20101128 16:09:57.088000> id=1 symbol=CBA bidSize: 0
> <20101128 16:09:57.088000> id=1 symbol=CBA askSize: 0
> <20101128 16:09:57.088000> id=1 symbol=CBA lastPrice: 47.58
> <20101128 16:09:57.088000> id=1 symbol=CBA lastSize: 1403
> <20101128 16:09:57.088000> id=1 symbol=CBA lastTimestamp: 1290748224
> <20101128 16:09:57.088000> id=1 symbol=CBA highPrice: 0
> <20101128 16:09:57.088000> id=1 symbol=CBA lowPrice: 0
> <20101128 16:09:57.088000> id=1 symbol=CBA closePrice: 47.58
> <20101128 16:09:57.088000> id=1 symbol=CBA openPrice: 0
> <20101128 16:09:57.432000> id=1 symbol=CBA optionCallVolume: 1463
> <20101128 16:09:57.432000> id=1 symbol=CBA optionPutVolume: 2118
> <20101128 16:09:57.448000> id=1 symbol=CBA optionCallOpenInterest: 18531
> <20101128 16:09:57.448000> id=1 symbol=CBA optionPutOpenInterest: 35375
> <20101128 16:09:57.448000> id=1 symbol=CBA optionHistoricalVol:
> 0.18530948012748838 NA
> <20101128 16:09:57.448000> id=1 symbol=CBA averageVolume: 5097538
> <20101128 16:09:57.448000> id=1 symbol=CBA 13-week High: 54.15000153
> <20101128 16:09:57.448000> id=1 symbol=CBA 13-week Low: 47.75999832
> <20101128 16:09:57.448000> id=1 symbol=CBA 26-week High: 54.15000153
> <20101128 16:09:57.448000> id=1 symbol=CBA 26-week Low: 44.62139893
> <20101128 16:09:57.448000> id=1 symbol=CBA 52-week High: 57.57139969
> <20101128 16:09:57.448000> id=1 symbol=CBA 52-week Low: 44.62139893
> <20101128 16:10:22.698000> id=1 symbol=CBA openPrice: 0
> <20101128 16:10:22.698000> id=1 symbol=CBA highPrice: 0
> <20101128 16:10:22.698000> id=1 symbol=CBA lowPrice: 0
> <20101128 16:10:22.698000> id=1 symbol=CBA closePrice: 47.58
>
>
>> reqHistoricalData(tws, twsEquity("CBA", exch='ASX'))
> waiting for TWS reply .....
> Error: Unable to complete historical data request
> In addition: Warning message:
> In errorHandler(con, verbose, OK = c(165, 300, 366, 2104, 2106,  :
>  No security definition has been found for the request.
>> reqContractsDetails(tws, twsEquity("CBA", exch='ASX'))
> Error: could not find function "reqContractsDetails"
>> reqContractDetails(tws, twsEquity("CBA", exch='ASX'))
> list()
> Warning message:
> In reqContractDetails(tws, twsEquity("CBA", exch = "ASX")) :
>  error in contract details
>> reqMktDepth(tws, twsEquity("CBA", exch='ASX'))
> TWS Message: 2 1 200 No security definition has been found for the request
>
>> reqRealTimeBars(tws, twsEquity("CBA", exch='ASX'))
> TWS Message: 2 1 310 Can't find the subscribed market depth with tickerId:1
> TWS Message: 2 1 200 No security definition has been found for the request
>
> reqMktData worked but none of the others did.  It could be something as
> simple as  the market being closed,  but maybe someone with more experience
> than I can advise me.
>
> Incidentally, can anyone  point me to code examples and/or tutorials.   I've
> read Real Time Market Data and Trade Execution with R by Jeffrey (and his
> reference card) but the example 2.5 is missing.  I've read Kyle Matoba's
> work as well but I would love to find more.
>
> Any help/comments most appreciated.
>
>
> --
> Stephen Choularton Ph.D., FIoD
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>



-- 
Jeffrey Ryan    |    Founder    |    jeffrey.ryan at lemnica.com

www.lemnica.com



More information about the R-SIG-Finance mailing list