Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.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。。。无法获取当天的OHLCV符号数据_R_Quantmod - Fatal编程技术网

R quantmod。。。无法获取当天的OHLCV符号数据

R quantmod。。。无法获取当天的OHLCV符号数据,r,quantmod,R,Quantmod,我无法使用QuantmodgetSymbols()call从雅虎获取当天的OHLCV数据。数据存在于yahoo上,也可以在我的图表平台上看到今天的OHLCV数据。作为解决方法,我使用getQuote(…)call从雅虎获得了今天的EOD报价。但是,当我试图通过rbind将其附加到下载的符号数据时,数据对象会填充null 对于如何将今天的报价附加到下载的历史符号数据或我可以在上市后调用的任何R API以获取符号EOD(OHLCV数据)的任何建议,包括今天的建议,我表示感谢。谢谢 library(q

我无法使用Quantmod
getSymbols()
call从雅虎获取当天的OHLCV数据。数据存在于yahoo上,也可以在我的图表平台上看到今天的OHLCV数据。作为解决方法,我使用
getQuote(…)
call从雅虎获得了今天的EOD报价。但是,当我试图通过rbind将其附加到下载的符号数据时,数据对象会填充null

对于如何将今天的报价附加到下载的历史符号数据或我可以在上市后调用的任何R API以获取符号EOD(OHLCV数据)的任何建议,包括今天的建议,我表示感谢。谢谢

library(quantmod)
library(blotter) 
library(PerformanceAnalytics)

getSymbols("SPY")
spy.quote = getQuote("SPY", what = yahooQuote.EOD)

> tail(SPY, n=3)
           SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
2012-10-25   142.02   142.28  140.57    141.43  134457400       141.43
2012-10-26   141.30   141.84  140.39    141.35  146023500       141.35
2012-10-31   141.85   142.03  140.68    141.35  103341300       141.35

> spy.quote
             Trade Time   Open   High    Low  Close    Volume
SPY 2012-11-01 04:00:00 141.65 143.01 141.52 142.83 100990760

> SPY = rbind(SPY, spy.quote)
> tail(SPY, n=3)
          SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
          NULL     NULL     NULL    NULL      NULL       NULL               
          NULL     NULL     NULL    NULL      NULL       NULL        
spy.quote NULL     NULL     NULL    NULL      NULL       NULL  

您需要将报价数据从
data.frame
转换为
xts
对象,并为调整后的价格添加一列。然后您可以
rbind

getSymbols("SPY", src='yahoo', to='2012-10-31')
spy.quote = getQuote("SPY", what = yahooQuote.EOD)

# convert to xts
xts.quote <- xts(spy.quote[, -1], as.Date(spy.quote[, 1])) # use Date for indexClass
xts.quote$Adjusted <- xts.quote[, 'Close'] # add an Adjusted column

tail(rbind(SPY, xts.quote), 3)
           SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
2012-10-26   141.30   141.84  140.39    141.35  146023500       141.35
2012-10-31   141.85   142.03  140.68    141.35  103341300       141.35
2012-11-01   141.65   143.01  141.52    142.83  100995568       142.83
getSymbols(“间谍”,src='yahoo',to='2012-10-31')
spy.quote=getQuote(“spy”,what=yahooQuote.EOD)
#转换为xts
xts.quote