用R下载库存数据

时间:2014-06-26 01:51:01

标签: r

我试图用R代码下载股票数据:

#load packages
library(stockPortfolio)
library(quadprog)

#get data of returns
stocks <- c(
  "SPY",
  "EFA",
  "IWM",
  "VWO",
  "LQD",
  "HYG")

returns <- getReturns(names(stocks), freq="week")

但是我收到了这个错误:

it's not possible to open the connection: HTTP status: '404 not found'

1 个答案:

答案 0 :(得分:2)

#load packages
library(stockPortfolio)
library(quadprog)

#get data of returns
stocks <- c(
  "SPY",
  "EFA",
  "IWM",
  "VWO",
  "LQD",
  "HYG")

returns <- getReturns(stocks, freq="week")

returns
Time Scale: week 

Average Return
         SPY          EFA          IWM          VWO          LQD          HYG 
0.0011957600 0.0002371890 0.0012480337 0.0005973494 0.0011942381 0.0012353135