为什么使用 quantmod 时开盘价、高价、低价是错误的? [英] Why Open,High,Low prices are wrong when using quantmod?

查看:12
本文介绍了为什么使用 quantmod 时开盘价、高价、低价是错误的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每周都使用此代码,但是,当我今天尝试时,我得到了错误的 OHL 和 SPY.Adjusted 结果,查看收盘价和交易量,它们似乎是正确的,那么有什么问题呢?

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 时开盘价、高价、低价是错误的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆