[R-SIG-Finance] problem with reqMktData

Stephen Choularton @tephen @ending from org@nicfoodm@rket@@com@@u
Thu Oct 18 12:51:04 CEST 2018


Hi

I can use this code to get historic data:

library("IBrokers")

sym1 <- 'ZS'
mkt1 <- 'ECBOT'
sym2 <- 'ZC'
mkt2 <- 'ECBOT'

contract1 <- twsContract(0,sym1, "CONTFUT", 
mkt1,"","","0.0","USD","","","",NULL,NULL,"0")

reqHistoricalData(tws, contract1, endDateTime = format(Sys.Date(), 
"%Y%m%d 24:00:00"), duration = "3 M")

but I can't get the code below to work

reqMktData(tws, contract1)

nor if I put a maturity in and use the same call like this

contract1 <- twsContract(0,sym1, "CONTFUT", 
mkt1,"","20181114","0.0","USD","","","",NULL,NULL,"0")

or

contract1 <- twsContract(0,sym1, "CONTFUT", 
mkt1,"","201811","0.0","USD","","","",NULL,NULL,"0")

although TWS specified this contract matures on 14 Nov.

All I get is:

TWS Message: 2 1 300 Can't find EId with tickerId:1
TWS Message: 2 1 321 Error validating request:-'bN' : cause - Please 
enter a valid security type

I have tried all sorts of alternates on the date but can't make it work 
and I tried this which I found on the web which was claimed to work:

     contract = 
twsFuture(symbol="ES",exch="GLOBEX",primary="GLOBEX",currency="USD",expiry="20171215")
     ESHistorical = reqHistoricalData(tws, contract)
     ESRealTime = reqMktData(tws, contract)

but got a different error message:

TWS Message: 2 1 300 Can't find EId with tickerId:1
TWS Message: 2 1 200 No security definition has been found for the request

Can anyone tell me where I have gone wrong with my own definition?


----------------------------------------------------------------------------------------------------------------------------------- 

Stephen Choularton PhD, FIoD



More information about the R-SIG-Finance mailing list