【发布时间】:2019-03-04 09:11:44
【问题描述】:
我使用 quantmod-package 从雅虎下载了调整后的收盘价,并用它创建了一个由 50% AAPL- 和 50% FB-stocks 组成的投资组合。
当我绘制我的投资组合的累积表现时,我得到的表现(可疑)很高,因为它高于 100%:
library(ggplot2)
library(quantmod)
cmp <- "AAPL"
getSymbols(Symbols = cmp)
tail(AAPL$AAPL.Adjusted)
cmp <- "FB"
getSymbols(Symbols = cmp)
tail(FB$FB.Adjusted)
df <- data.frame("AAPL" = tail(AAPL$AAPL.Adjusted, 1000),
"FB" = tail(FB$FB.Adjusted, 1000))
for(i in 2:nrow(df)){
df$AAPL.Adjusted_prc[i] <- df$AAPL.Adjusted[i]/df$AAPL.Adjusted[i-1]-1
df$FB.Adjusted_prc[i] <- df$FB.Adjusted[i]/df$FB.Adjusted[i-1]-1
}
df <- df[-1,]
df$portfolio <- (df$AAPL.Adjusted_prc + df$FB.Adjusted_prc)*0.5
df$performance <- cumprod(df$portfolio+1)-1
df$idu <- as.Date(row.names(df))
ggplot(data = df, aes(x = idu, y = performance)) + geom_line()
对我来说,超过 100% 的累积表现似乎很不现实。这让我想到,也许有必要在使用之前调整/缩放从quantmod 下载的数据?
【问题讨论】:
-
AAPL 现在的交易价格约为 175 美元。 2015 年 3 月,它约为 118 美元,根据拆分和股息进行了调整。 FB 大约是 162 美元,当时大约是 80 美元。这些数字看起来与您的回报率一致,比 100% 更接近 85%。
标签: r finance quantmod yahoo-api quantitative-finance