R stockPortfolio软件包未连接到Yahoo [英] R stockPortfolio Package not connecting to Yahoo

查看:112
本文介绍了R stockPortfolio软件包未连接到Yahoo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试复制此示例,因为我是通过R进行投资组合优化的新手.

I am trying to replicate this example as I am new to portfolio optimization through R:

http://economistatlarge.com/portfolio-theory/r-optimized-portfolio

但是,我不断收到以下错误消息:

However, I keep getting the following error:

    R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(stockPortfolio)
Warning message:
package ‘stockPortfolio’ was built under R version 3.1.1 
> library(quadprog)
Warning message:
package ‘quadprog’ was built under R version 3.1.1 
> stocks <- c(
+ "SPY" = .30,
+ "EFA" = .20,
+ "IWM" = .15,
+ "VWO" = .10,
+ "LQD" = .15,
+ "HYG" = .10)
> returns <- getReturns(names(stocks), freq="week")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  unable to connect to 'ichart.finance.yahoo.com' on port 80.

我不知道如何解决这个问题,有什么建议吗?

I have no idea how to troubleshoot this, any suggestions?

推荐答案

这可能不是导致错误的确切答案.但这只是一个起点.另外,对于维护已安装软件包的适当的预期功能非常重要.

This may not be the exact answer to what is causing the error. But it is intended as a starting point. Plus, it's very important for maintaining proper, intended functionality of installed packages.

在代码顶部,您的R版本是

From the top of your code, your R version is

R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"

如果在使用library(或require)附加包装时收到警告消息,则应该引起您的注意.您的代码显示以下警告消息.

If you get a warning message when you attach a package with library (or require), that should spark your interest. Your code shows the following warning messages.

> library(stockPortfolio)
# Warning message:
# package ‘stockPortfolio’ was built under R version 3.1.1 
> library(quadprog)
# Warning message:
# package ‘quadprog’ was built under R version 3.1.1 

您的程序包是使用比您使用的更高版本的R构建的.这可能是由于代码更改或其他原因引起的问题.

Your packages were built with a newer version of R than you are using. This may be causing the problem because of changes in code or other things.

我建议您更新到R的最新版本,然后重试.

I recommend you update to the latest version of R and then try again.

这篇关于R stockPortfolio软件包未连接到Yahoo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆