我正在关注本教程: http ://systematicinvestor.wordpress.com/2012/01/29/multiple-factor-model-fundamental-data/
当我运行第一个脚本时,我得到了许多错误,例如
url 错误(“ http://www.systematicportfolio.com/sit.gz”,“rb ”):无法打开连接
任何人都可以提供有关如何使用它的指导吗?
我正在关注本教程: http ://systematicinvestor.wordpress.com/2012/01/29/multiple-factor-model-fundamental-data/
当我运行第一个脚本时,我得到了许多错误,例如
url 错误(“ http://www.systematicportfolio.com/sit.gz”,“rb ”):无法打开连接
任何人都可以提供有关如何使用它的指导吗?
In the first few lines of the code, you see the following:
###############################################################################
# Load Systematic Investor Toolbox (SIT)
# http://systematicinvestor.wordpress.com/systematic-investor-toolbox/
###############################################################################
Follow that URL, and you will find alternative methods to load the "SIT". For me (as suggested by @RicardoSaporta) the one that popped out as most likely to work in a general manner (because of https, binary files, and so on) was the RCurl
method. (Be sure you have RCurl installed first!)
###############################################################################
# Load Systematic Investor Toolbox (SIT): Requires RCurl package
###############################################################################
require(RCurl)
sit = getURLContent('https://github.com/systematicinvestor/SIT/raw/master/sit.gz', binary=TRUE, followlocation = TRUE, ssl.verifypeer = FALSE)
con = gzcon(rawConnection(sit, 'rb'))
source(con)
close(con)
Use that for the first few lines and you should be able to process the rest of the code.
Alternatively, manually download the file from https://github.com/systematicinvestor/SIT/raw/master/sit.gz and load it with:
con = gzcon(file('path/to/sit.gz', 'rb')) ## Replace with actual path
source(con)
close(con)
and proceed from there.
Beyond that, the blog post you linked to doesn't mention a critical piece of information: what packages you need to have installed and loaded. You need to install and load "xts" and "quantmod" before running the rest of the script.
install.packages("xts")
install.packages("quantmod")
library(xts)
library(quantmod)