Why is there a delay in getting opening trade price using quantmod

社会主义新天地 提交于 2021-02-19 07:01:06

问题


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

回答1:


There's a delay because Yahoo Finance delays their real-time data for most exchanges.



来源:https://stackoverflow.com/questions/34995391/why-is-there-a-delay-in-getting-opening-trade-price-using-quantmod

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!