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
problem with reqMktData
2 messages · Stephen Choularton, Enrico Schumann
On Do, 18 Okt 2018, Stephen Choularton writes:
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
I don't think you can request market data for
continuous contracts. As the IB docs say:
,----
| Continuous futures are available from the API with TWS
| v971 and higher. Continuous futures cannot be used with
| real time data or to place orders, but only for
| historical data.
`----
If I understand you correctly, you want data for
the soybeans Nov-18 future?
,----
| library("IBrokers")
| tws <- twsConnect()
| contract1 <- twsContract(
| local = "ZS NOV 18",
| sectype = "FUT",
| exch = "ECBOT",
| currency = "USD",
| include_expired = "1",
| conId = "", symbol = "",
| primary = "", expiry = "",
| strike = "", right = "",
| multiplier = "", combo_legs_desc = "",
| comboleg = "", secIdType = "", secId = "")
| reqMktData(tws, contract1)
`----
See the description for the contract specification here:
https://github.com/enricoschumann/IButils#finding-the-contract-specification
Enrico Schumann Lucerne, Switzerland http://enricoschumann.net