Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 为什么使用quantmod获取开盘交易价格会有延迟_R_Quantmod - Fatal编程技术网

R 为什么使用quantmod获取开盘交易价格会有延迟

R 为什么使用quantmod获取开盘交易价格会有延迟,r,quantmod,R,Quantmod,我正在使用quantmod软件包进行交易,但在最近几天,当我在美国东部时间上午9:30市场开放时间运行代码时,我在获取开放日价格(SPY)方面遇到了延迟。大约10分钟后,一切都很好,我得到了数字,但我怎么能绕过这个延迟?是因为我的代码还是其他原因? 我使用quantmod版本0.4-4 # rm(list = ls()) # generally considered as bad manner in an MWE require(quantmod) options(scipen=999) sp

我正在使用quantmod软件包进行交易,但在最近几天,当我在美国东部时间上午9:30市场开放时间运行代码时,我在获取开放日价格(SPY)方面遇到了延迟。大约10分钟后,一切都很好,我得到了数字,但我怎么能绕过这个延迟?是因为我的代码还是其他原因? 我使用quantmod版本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
#rm(list=ls())#在MWE中通常被认为是不好的方式
需要(quantmod)
选项(scipen=999)

spy有延迟,因为。

你好@Pascal,你没有遇到延迟吗?对我来说,在市场开盘15分钟后,我得到了SPY的每日开盘价。我不确定这是因为雅虎方面的延迟还是因为我的代码。没有延迟。我马上就知道了。也许是延迟。你现在试过了吗?还有,我得到任何警告。您的
quantmod
的版本是什么?版本是0.4-4。延迟仅在开放时间,如果我现在运行它,它将正常工作,但在开放时间,它无法获得大约10-20分钟的每日开放价格。(它可以很好地获取历史数据)。不清楚您在什么时候运行代码。如果它现在运行,但不是更早或更晚,我就无能为力了。只是为了澄清一下:我在美国东部标准时间上午9:30的市场开放时间运行代码,那么我如何才能获得实时数据?