[R-SIG-Finance] reqHistoricalData
Stephen Choularton
stephen at organicfoodmarkets.com.au
Thu Dec 23 20:48:45 CET 2010
Following the logic Jeff's reply to my Re: [R-SIG-Finance] placeOrder
posting, I have been trying to reqHistoricalData:
tws <- twsConnect()
tws
reqHistoricalData(tws, twsContract(conId='45998522', symbol='BHP',
sectype='STK', exch='SNFE', primary='', expiry='', strike='',
currency="AUD", right= "", local = "BJK6", multiplier= "",
combo_legs_desc= "", comboleg= "", include_expired= "", secIdType = "",
secId = ""))
closeAllConnections()
but failing:
> tws <- twsConnect()
> tws
<twsConnection,1 @ 20101224 06:11:21 Eastern Standard Time (New South
Wales), nextId=64>
> reqHistoricalData(tws, twsContract(conId='45998522', symbol='BHP',
sectype='STK', exch='SNFE', primary='', expiry='', strike='',
currency="AUD", right= "", local = "BJK6", multiplier= "",
combo_legs_desc= "", comboleg= "", include_expired= "",
secIdType = "", secId = ""))
TWS Message: 2 -1 2104 Market data farm connection is OK:aufarm
TWS Message: 2 -1 2106 HMDS data farm connection is OK:hkhmds2
TWS Message: 2 -1 2106 HMDS data farm connection is OK:ushmds2a
waiting for TWS reply ....NULL
Warning message:
In errorHandler(con, verbose, OK = c(165, 300, 366, 2104, 2106, :
No security definition has been found for the request
>
> #reqHistoricalData(tws, 'BHP', 'CFD', 'SNFE', 'AUD',duration = '1 M')
> closeAllConnections()
I'm pretty sure I have the contract correct:
> tws <- twsConnect()
> tws
<twsConnection,1 @ 20101224 06:17:03 Eastern Standard Time (New South
Wales), nextId=64>
> bhp_cfd <- twsContract("", "BHP", "CFD", "SNFE", "", "", "", "AUD",
"","","",NULL,NULL,0)
> reqContractDetails(tws, bhp_cfd)[[1]]
List of 18
$ version : chr "6"
$ contract :List of 16
..$ conId : chr "45998522"
..$ symbol : chr "BHP"
..$ sectype : chr "CFD"
..$ exch : chr "SNFE"
..$ primary : chr ""
..$ expiry : chr ""
..$ strike : chr "0"
..$ currency : chr "AUD"
..$ right : chr ""
..$ local : chr "BJK6"
..$ multiplier : chr ""
..$ combo_legs_desc: chr ""
..$ comboleg : chr ""
..$ include_expired: chr ""
..$ secIdType : chr ""
..$ secId : chr ""
..- attr(*, "class")= chr "twsContract"
$ marketName : chr "BJ"
$ tradingClass : chr "BJ"
$ conId : chr "45998522"
$ minTick : chr "0.01"
$ orderTypes : chr [1:33] "ACTIVETIM" "ADJUST" "ALERT" "ALLOC" ...
$ validExchanges: chr "SNFE"
$ priceMagnifier: chr "1"
$ underConId : chr "4036812"
$ longName : chr "BHP BILLITON LIMITED"
$ contractMonth : chr ""
$ industry : chr "Basic Materials"
$ category : chr "Mining"
$ subcategory : chr "Diversified Minerals"
$ timeZoneId : chr "AET"
$ tradingHours : chr "20101224:1000-1400;20101229:1000-1600"
$ liquidHours : chr "20101224:1000-1400;20101229:1000-1600"
> closeAllConnections()
>
I wonder where I am going wrong.
Stephen Choularton Ph.D., FIoD
On 17/12/2010 3:05 AM, Jeff Ryan wrote:
> reqContractDetails(tws, cba_cfd)[[1]]
More information about the R-SIG-Finance
mailing list