Question

I've tried the following to get the AAPL option chain with expiration date April 19 2014:

try1 <- getOptionChain("AAPL",Exp="2014-04-19")
try2 <- getOptionChain("AAPL",Exp=as.Date("2014-04-19"))

Results of both are identical and seem to be all options expiring in April:

> try1$puts
                     Strike   Last    Chg    Bid    Ask  Vol    OI
AAPL140419P00200000   200.0   0.05   0.00     NA   0.05    1    37
# <snip>
AAPL140411P00470000   470.0   0.30   0.05   0.25   0.42   10    43
# <snip>

The above snips of the chain shows options for April 19 2014 but also e.g. April 11 2014.

What am I doing wrong? I am running "R 3.0.2 GUI 1.62 Snow Leopard build (6558)" with new quantmod install from CRAN.

Was it helpful?

Solution

getOptionChain scrapes the data from Yahoo's webpage. Yahoo only provides data by expiration month, not by the specific day.

You can use the expiry function in the greeks package to determine which contracts expire on a specific day:

> head(try1$puts[as.Date(expiry(rownames(try1$puts))) == "2014-04-19",])
                    Strike Last Chg Bid Ask Vol OI
AAPL140419P00200000    200 0.05   0  NA  NA   1 37
AAPL140419P00205000    205 0.15   0  NA  NA   0 25
AAPL140419P00210000    210 0.35   0  NA  NA   0 11
AAPL140419P00215000    215 0.01   0  NA  NA   2  9
AAPL140419P00220000    220 0.13   0  NA  NA   0 23
AAPL140419P00225000    225 0.80   0  NA  NA   0 12

Note that you will have to build and install the greeks package from source yourself.

Or you can grep for the date yourself:

> head(try1$puts[grepl("140419", rownames(try1$puts)),])
                    Strike Last Chg Bid Ask Vol OI
AAPL140419P00200000    200 0.05   0  NA  NA   1 37
AAPL140419P00205000    205 0.15   0  NA  NA   0 25
AAPL140419P00210000    210 0.35   0  NA  NA   0 11
AAPL140419P00215000    215 0.01   0  NA  NA   2  9
AAPL140419P00220000    220 0.13   0  NA  NA   0 23
AAPL140419P00225000    225 0.80   0  NA  NA   0 12
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top