Come posso ottenere i dati storici di un INDICE in R da Interactive Brokers? Se fosse a termine, vorrei utilizzare questo comando (come suggerito qui IBrokers request Historical Futures Contract Data?):IBrokers Historical Index Data
library(twsInstrument)
a <- reqHistoricalData(tws, getContract("ESJUN2013"))
Ma il corrispondente comando con l'connid
della S & P Index dà un errore:
> a <- reqHistoricalData(tws, getContract("11004968"))
Connected with clientId 110.
Contract details request complete. Disconnected.
waiting for TWS reply on ES ....failed.
Warning message:
In errorHandler(con, verbose, OK = c(165, 300, 366, 2104, 2106, :
Error validating request:-'uc' : cause - HMDS Expired Contract Violation:contract can not expire.
P.S. Qualcuno con abbastanza punti dovrebbe creare un tag per IBrokers
Dove hai ottenuto che 'CONId' (" 11004968 ")? Se si desidera l'indice S & P, è necessario ottenere il [contratto SPX] (http://www1.interactivebrokers.ch/contract_info/v3.8/index.php?action=Details&site=GEN&conid=416904). Puoi farlo con 'getContract (" SPX ")', 'getContract (sintetico (" SPX "," USD "))', 'getContract (" 416904 ")' ecc. Se vuoi usare [twsInstrument] (https : //r-forge.r-project.org/R/? group_id = 1113), o usa 'twsIndex' da [IBrokers] (https://code.google.com/p/ibrokers/) come dimostrato da geektrader. – GSee