0
xtsオブジェクトの毎日の値を毎月の有効期限OHLCVデータに変更したいとします。私は、集約された月次データのタイムスタンプは、(あなたがタイムスタンプ値のために起動したり、バーの端たいん慎重に考慮して、あなたがOHLCVを自分でバー作成することができます...私はそうするquantmod::options.expiry
を使用することができます毎月のxts値を毎月のオプション有効期限に変更します。OHLCV xts in R
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