joshuaulrich / quantmod

Quantitative Financial Modelling Framework
http://www.quantmod.com/
GNU General Public License v3.0
814 stars 224 forks source link

getOptionChain() does not work for SPX when "exp" is set to NULL or certain year like "2017/2018" #139

Closed alitiffany closed 7 years ago

alitiffany commented 7 years ago

Thanks a lot for your great work of quantmod! But the function getOptionChain does not work in my computer for SPX when "exp" is set to NULL or certain year like "2017/2018" and I can not figure out why. My session info is listed below and any help would be appreciated.

R version 3.2.3 (2015-12-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

locale: [1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936 [2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936 [4] LC_NUMERIC=C
[5] LC_TIME=C

attached base packages: character(0)

other attached packages: [1] quantmod_0.4-7

joshuaulrich commented 7 years ago

Please provide a reproducible example. There's no data for the "SPX" ticker on Yahoo Finance, so I wouldn't expect any data to be returned from getOptionChain, getSymbols, etc.

alitiffany commented 7 years ago

Thanks for your reply. Examples are listed below and it seems that the getOptionChain works for SPY but not ^SPX.

> optionPool <- getOptionChain("^SPX", "2017/2018")
Error in open.connection(con, "rb") : SSL connect error
> optionPool <- getOptionChain("^SPX", NULL)
Error in data.frame(Strike = strike, Last = lastprice, Chg = change, Bid = bid,  : 
  object 'contractsymbol' not found
> optionPool <- getOptionChain("SPY", "2017/2018")
> optionPool <- getOptionChain("^SPX")
alitiffany commented 7 years ago

I tried former package versions but cannot get proper results, neither. The function is fundamental to my assignment so that I do appreciate your help to solve this problem.

braverock commented 7 years ago

^SPX is an index, not a tradeable instrument.

Options on the S&P 500 trade mostly on the CME. The contract specification is here:

http://www.cmegroup.com/trading/equity-index/us-index/sandp-500_contractSpecs_options.html?gclid=Cj0KEQiA_eXEBRDP8fnIlJDXxsIBEiQAAGfyoZocwVofoGekXoGMyliQbVGf5Z22YLZtaeu8hC_BgUEaArxm8P8HAQ&gclsrc=aw.ds

Note that the symbol is not '^SPX'.

Of course, I have no idea what Yahoo's symbol is, or if Yahoo provides this data.

SPY is the index ETF, and options on SPY also trade.

Closing this issue as not a bug.

joshuaulrich commented 7 years ago

Thanks for the reproducible example. As I said with "SPX", there is no "^SPX" ticker on Yahoo Finance, so I wouldn't expect any quantmod functions to return data.

This issue tracker is for bugs and other issues with the code. Your questions involve understanding how the functions work, and what data are available. Please post general questions like this to the R-SIG-Finance mailing list (you must subscribe to post).