为什么使用 quantmod 获取开盘交易价格会出现延迟 [英] Why is there a delay in getting opening trade price using quantmod
本文介绍了为什么使用 quantmod 获取开盘交易价格会出现延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 quantmod 包进行交易,但在过去的几天里,当我在美国东部标准时间上午 9:30 的市场开放时间运行我的代码时,我在获得每日开盘价 (SPY) 方面出现了延迟.大约 10 分钟后,一切都很好,我得到了数字,但我怎样才能绕过这个延迟?是因为我的代码还是其他原因?我使用 quantmod 版本 0.4-4.
I'm using quantmod package for my trading but in the last few days I get a delay in getting the open daily price ( SPY ) when I run my code on market open time 9:30 AM EST. After about 10 minutes all is working great and I get the numbers but how can I bypass this delay ? Is it because of my code or another reason? I use quantmod Version 0.4-4.
# rm(list = ls()) # generally considered as bad manner in an MWE
require(quantmod)
options(scipen=999)
spy <- getSymbols(("SPY") , src = 'yahoo', from = '2007-01-01', auto.assign = T)
Warning message:
In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
downloaded length 168806 != reported length 200
spy<-cbind(SPY)
q <- getQuote("SPY") # adds the current trade row
qCols <- c("Open","High","Low","Last","Volume","Last")
qx <- xts(q[,qCols], as.Date(q[,"Trade Time"]))
SPY <- rbind(SPY, qx)
Warning messages:
1: In rbind(deparse.level, ...) :
mismatched types: converting objects to numeric
2: In rbind(deparse.level, ...) : NAs introduced by coercion
推荐答案
有一个延迟,因为 雅虎财经延迟了他们的实际-大多数交易所的时间数据.
这篇关于为什么使用 quantmod 获取开盘交易价格会出现延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文