Monthly Return 함수를 사용하여 monthlyReturn에 배당량을 고려하는 방법이 있습니까?QuantMod/tseries monthlyReturn with dividend
가격 및 배당금 항목이 포함 된 xts 개체가 있습니다.
Monthly Return 함수를 사용하여 monthlyReturn에 배당량을 고려하는 방법이 있습니까?QuantMod/tseries monthlyReturn with dividend
가격 및 배당금 항목이 포함 된 xts 개체가 있습니다.
TTR::adjRatios
을 직접 사용하여 "총 수익"가격 시리즈를 만드는 데 필요한 조정 비율을 계산할 수 있습니다. 그런 다음 조정 된 시리즈를 사용하여 월별 수익을 계산할 수 있습니다. 스플릿을 조정해야 할 수도 있습니다.
library(quantmod)
# create sample data
SPY.Close <- Cl(getSymbols("SPY", auto.assign=FALSE))
SPY.Div <- getDividends("SPY", auto.assign=FALSE)
SPY <- merge(SPY.Close, SPY.Div)
# now adjust close for dividends
ratios <- adjRatios(dividends=SPY[,"SPY.Div"], close=SPY[,"SPY.Close"])
SPY$SPY.Adjusted <- (ratios$Split * ratios$Div) * SPY$SPY.Close
# only keep dates from the original object
SPY <- SPY[index(SPY.Close),]
# calculate returns on raw prices and adjusted prices
ret <- merge(monthlyReturn(Cl(SPY)), monthlyReturn(Ad(SPY)))
가격 및 배당금 항목을 함께 추가하고 이에 대해'monthlyReturn'을 실행하십시오. – GSee
@GSee, 나는 그렇게 생각하지 않았다. 한 달 중순 배당금이 발생하면 수익을 계산할 때 문제가 될 수 있습니다. – firstever
오. 네가하는 말을 나는 생각한다. – GSee