This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 安装xlsReadWrite包之后要运行xls.getshlib() | |
# 但是 http://dl.dropbox.com/u/2602516/swissrpkg/bin/win32/shlib/xlsReadWrite_1.5.4_dll.zip 在墙外 | |
# 所以找人下载之后放在本地web服务器上 http://127.0.0.1/download/win32/shlib/xlsReadWrite_1.5.4_dll.zip | |
# 运行的时候 用 xls.getshlib(md5=FALSE) | |
xls.getshlib <- function (pkgvers = NA, url = NA, md5 = TRUE, reload.shlib = TRUE, | |
tmpdir = tempdir()) | |
{ | |
require(tools) | |
printmsg <- function(x) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="wrapper"> | |
{% for post in paginator.posts %} | |
<div class="article"> | |
<h1> | |
<span>{{ post.date | date: "%b %d, %Y" }}</span> | |
<a href="{{ post.url }}">{{ post.title }}</a> | |
</h1> | |
{{ post.content}} | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 从大连商品交易所网站抓取价格数据 数据源 http://www.dce.com.cn/PublicWeb/MainServlet?action=Pu00011_search | |
# 接口举例 http://www.dce.com.cn/PublicWeb/MainServlet?Pu00011_Input.trade_date=20121206&Pu00011_Input.trade_type=0&Pu00011_Input.variety=a&action=Pu00012_download | |
# Pu00011_Input.trade_date : 查询的日期 | |
# Pu00011_Input.trade_type : 行情类别 0为期货,1为期权(未开通) | |
# Pu00011_Input.variety : 期货品种代码,各代码表示的期货品种: | |
# a : 豆一 | |
# b : 豆二 | |
# c : 玉米 | |
# j :焦炭 | |
# l : 聚乙烯 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 读取郑州商品交易所数据 | |
# 接口举例 | |
# (1) http://www.czce.com.cn/portal/exchange/2012/datadaily/20121205.htm | |
# (2) http://www.czce.com.cn/portal/exchange/2012/datadaily/20121205.txt | |
zceDatabase <- NULL | |
for(date in c("20121202","20121206")){ | |
str <- "http://www.czce.com.cn/portal/exchange/2012/datadaily/" | |
url <- paste(str,date,".txt",sep="") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 获取上海期货交易所数据 | |
# 接口举例 http://www.shfe.com.cn/dailydata/kx/kx20121206.html | |
require(XML) | |
require(stringr) | |
shfeDatabase <- NULL | |
for (date in dates) { | |
str <- "http://www.shfe.com.cn/dailydata/kx/kx" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read Exchange Rate from the Federal Reserve Bank of New York | |
# website is http://www.federalreserve.gov/releases/h10/hist/ | |
# For example read the exchange rate of Australian Dollar | |
require(RCurl) | |
require(XML) | |
require(stringr) | |
setwd("F:/") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 从复旦人民币汇率指数网站读取数据 http://ifsfd.fudan.edu.cn/fdurmb/indexchart1.jsp | |
# 更多细节请看 http://cos.name/cn/topic/109132 | |
require(RCurl) | |
require(rjson) | |
fdjson <- getURL("http://ifsfd.fudan.edu.cn/fdurmb/data?df=2000%2F01%2F03&type=0%2C1%2C2&dt=2013%2F01%2F16") | |
fdlist <- fromJSON(fdjson) | |
fdm <-matrix(unlist(fdlist),ncol=4,byrow=T) | |
fddf <- data.frame(fdm, stringsAsFactors = F) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cntrade R语言版 | |
# 作者:陈堰平(新华指数有限责任公司,[email protected]) | |
# 使用网易股票数据接口 原stata版的作者为: | |
# 李春涛(中南财经政法大学,[email protected]) | |
# 张璇(中南财经政法大学,[email protected]) | |
# example: | |
# cntrade(c('600000', '000008'), path ='D:/stockprice', start = '20010104', end = '20120124') | |
cntrade <- function(tickers, path = "", start = "19910101", end = "") { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# readHexun.r | |
# 从和讯读取财务数据 | |
readHexun <- function(stockid, year, accountdate ){ | |
if(accountdate == 1){ | |
ad <- paste(year,".03.15",sep="") | |
}else if(accountdate == 2){ | |
ad <- paste(year,".06.30",sep="") | |
}else if(accountdate == 3){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# getHexunFinaceData.r | |
# 从和讯读取财务数据 | |
# version: 0.93 | |
# 调用语法: | |
# getHexunFinaceData(stockid, start, end, type) | |
# 参数含义: | |
# stockid 股票代码 | |
# start 起始年份 | |
# end 结束年份 | |
# type 财务报告类别,默认为"b",表示资产负债表;"i"表示利润表;"c"表示现金流量表 |