【问题标题】:Manually adjusted closing price doesn't match with Yahoo Finance Adjusted Price手动调整收盘价与雅虎财经调整价不符
【发布时间】:2020-07-09 17:14:36
【问题描述】:

尝试在 R 中运行以下代码,但手动调整的收盘价与 Yahoo 提供的不匹配。不是说差别很小,而是差别很大。我在这里遗漏了什么吗?

代码如下:


library(quantmod)

getSymbols("AAPL")

splits<- getSplits("AAPL")

raw_dividends<- getDividends("AAPL", split.adjust = F)

ratios <- adjRatios(splits = splits, dividends = raw_dividends, close = Cl(AAPL))

aapl_adjusted <- Cl(AAPL) * ratios[, "Split"] * ratios[, "Div"]

head(Ad(AAPL))

head(aapl_adjusted)

【问题讨论】:

  • 您能否提供一个可行的示例,即给我们一些数字并告诉我们其中的区别,好吗?

标签: r quantmod


【解决方案1】:

雅虎未经调整的价格并非真正未经调整。

R> head(AAPL)
##            AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted
## 2007-01-03  12.32714  12.36857 11.70000   11.97143   309579900      10.36364
## 2007-01-04  12.00714  12.27857 11.97429   12.23714   211815100      10.59366
## 2007-01-05  12.25286  12.31428 12.05714   12.15000   208685400      10.51822
## 2007-01-08  12.28000  12.36143 12.18286   12.21000   199276700      10.57016
## 2007-01-09  12.35000  13.28286 12.16429   13.22429   837324600      11.44823
## 2007-01-10  13.53571  13.97143 13.35000   13.85714   738220000      11.99609

AAPL 不会(也不会)以包含零头的价格进行交易。所以你的计算不匹配,因为你调整了两次拆分。

我的猜测是,雅虎会返回针对拆分调整的数据,而不是股息。这可以通过除以分流比来确认......

R> head(Cl(AAPL) / ratios[,"Split"])
##            AAPL.Close
## 2007-01-03   83.80000
## 2007-01-04   85.66000
## 2007-01-05   85.05000
## 2007-01-08   85.47000
## 2007-01-09   92.57000
## 2007-01-10   96.99999

这些价​​格与您从其他提供商处获得的价格相近。例如,这是tiingo 提供的内容。您需要一个(免费)API 密钥才能从他们那里下载数据。

R> head(getSymbols("AAPL", src = "tiingo", api.key = tiingo.key, auto.assign = FALSE))
##            AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume
## 2007-01-03     86.29     86.58    81.90      83.80    44225700
## 2007-01-04     84.05     85.95    83.82      85.66    30259300
## 2007-01-05     85.77     86.20    84.40      85.05    29812200
## 2007-01-08     85.96     86.53    85.28      85.47    28468100
## 2007-01-09     86.45     92.98    85.15      92.57   119617800
## 2007-01-10     94.75     97.80    93.45      97.00   105460000

【讨论】:

  • 感谢您的帮助。我正在学习的课程让我感到困惑。有点晚了,雅虎只根据原始股息进行调整,而不是拆分。
  • 如何在不对 Yahoo 数据进行任何调整的情况下恢复“原始”OHLC
【解决方案2】:

找出问题所在,雅虎只针对原始股息进行调整,而不是拆分。 乘以股息比率得到了我的确切答案。

> library(quantmod)
> getSymbols("AAPL")
[1] "AAPL"
> splits<- getSplits("AAPL")
> raw_dividends<- getDividends("AAPL", split.adjust = F)
> ratios <- adjRatios(splits = splits, dividends = raw_dividends, close = Cl(AAPL))
> aapl_adjusted <- Cl(AAPL) * ratios[,"Div"]
> head(Ad(AAPL))
           AAPL.Adjusted
2007-01-03      10.36364
2007-01-04      10.59366
2007-01-05      10.51822
2007-01-08      10.57016
2007-01-09      11.44823
2007-01-10      11.99609
> head(aapl_adjusted)
           AAPL.Close
2007-01-03   10.36363
2007-01-04   10.59366
2007-01-05   10.51822
2007-01-08   10.57016
2007-01-09   11.44823
2007-01-10   11.99609

【讨论】:

  • 虽然不是他们所说的here
猜你喜欢
  • 2020-05-05
  • 1970-01-01
  • 2013-11-06
  • 1970-01-01
  • 2012-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多