簡體   English   中英

用R下載庫存數據

[英]download stock data with 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'
#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 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM