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