为什么在使用Quantmod时,Open,High,Low价格是错误的? [英] Why Open,High,Low prices are wrong when using quantmod?
问题描述
我每周使用此代码,但是今天尝试使用此代码时,OHL和SPY的结果错误,调整后查看收盘价和交易量似乎正确,这又是怎么回事?
I use this code on a weekly basis, however, when I tried it today I got wrong results of OHL and SPY.Adjusted, looking at the Close prices and Volume they seem correct so what's wrong?
rm(list = ls())
options(scipen=999)
require(quantmod)
spy<-getSymbols("SPY", src = 'yahoo', from = '2007-05-31', auto.assign = T)
spy<-cbind(SPY)
dim(SPY)
head(SPY)
This the outcome from Yahoo:
Date Open High Low Close Adj Close* Volume
May 31, 2007 153.67 153.89 153.12 153.32 123.86 114,866,700
This is the outcome from the API( using quantmod):
SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
2007-05-31 190.217 190.489 189.536 153.32 114866700 123.8624
推荐答案
确认这是一个问题.雅虎一直在提供拆股调整后的开盘价,最高价,最低价和调整后的收盘价以及原始收盘价. getSymbols
使用调整后的价格和收盘价来调整未调整的开盘价,最高价和最低价.
Confirmed that this is an issue. Yahoo had been providing split-adjusted Open, High, Low, and Adjusted Close prices, and raw Close prices. getSymbols
used the adjusted and close prices to un-adjusted the Open, High, and Low prices.
现在看来,雅虎正在提供拆分和股息调整后的调整后收盘价.开盘价,最高价和最低价仍然是分开调整的,因此需要不进行调整,但是无法再使用平仓调整后的收盘价"比率.
Now it appears Yahoo is providing and Adjusted Close that is split- and dividend-adjusted. The Open, High, and Low prices are still split-adjusted, and therefore need to be unadjusted, but the Close-to-Adjusted-Close ratio can no longer be used.
这篇关于为什么在使用Quantmod时,Open,High,Low价格是错误的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!