0
我想将xts对象的每日价值更改为每月到期OHLCV数据。我想我可以用quantmod::options.expiry
这样做......将每日xts值更改为R月期权到期OHLCV xts
library("quantmod")
# get SPX daily values
SPX <- getSymbols("^GSPC",from="2016-01-01",auto.assign=FALSE)
# option expiration rows/dates using options.expiry()
spx_expiry <- SPX[options.expiry(SPX),]
# spx_expiry will only return the closing values for option expiration **day**
# it is missing the OHLCV data in between expiration months.
# The Close/Adjusted columns are correct but the Open, High, Low, Volumes
# columns are incorrect.
# Here is what I have tried:
period.apply(SPX,INDEX=options.expiry(SPX),FUN=function(x) to.monthly(x,indexAt='firstof'))
正是我在找什么。非常感谢! – Rime