带有到期日期的getOptionChain()似乎不限于指定的日期

时间:2021-01-19 12:34:21

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

我已尝试以下方法获得AAPL选项链,其截止日期为2014年4月19日:

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.

链的上述剪辑显示了2014年4月19日的选项,但也包括2014年4月11日。

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.

我究竟做错了什么?我使用CRAN的新quantmod安装运行“R 3.0.2 GUI 1.62 Snow Leopard build(6558)”。

1 个解决方案

#1


1  

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

getOptionChain从Yahoo的网页上抓取数据。 Yahoo仅在到期月份之前提供数据,而不是在特定日期提供数据。

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

您可以使用greeks包中的到期函数来确定哪些合约在特定日期到期:

> 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.

请注意,您必须自己从源代码构建和安装greeks包。

Or you can grep for the date yourself:

或者你可以自己grep日期:

> 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

#1


1  

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

getOptionChain从Yahoo的网页上抓取数据。 Yahoo仅在到期月份之前提供数据,而不是在特定日期提供数据。

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

您可以使用greeks包中的到期函数来确定哪些合约在特定日期到期:

> 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.

请注意,您必须自己从源代码构建和安装greeks包。

Or you can grep for the date yourself:

或者你可以自己grep日期:

> 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