Skip to content

Instantly share code, notes, and snippets.

Avatar

Yanping Chen yanping

View GitHub Profile
View 000-instructions.md

Building a beamer presentation with knitr.

Introduction

The documents included are the input for knitr. In addition you need to have the tool pandoc installed. I also use a custom beamer template to add the University of Utah \institute command to the template. It also changes the indentation some.

Steps

  1. knit document with
@yanping
yanping / getHexunFinaceData.r
Last active Apr 26, 2016
从和讯读取财务数据
View getHexunFinaceData.r
# getHexunFinaceData.r
# 从和讯读取财务数据
# version: 0.93
# 调用语法:
# getHexunFinaceData(stockid, start, end, type)
# 参数含义:
# stockid 股票代码
# start 起始年份
# end 结束年份
# type 财务报告类别,默认为"b",表示资产负债表;"i"表示利润表;"c"表示现金流量表
@yanping
yanping / readHexun.r
Last active Dec 11, 2015
从和讯网读取上市公司财务数据
View readHexun.r
# 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){
@yanping
yanping / cntrade.r
Last active Mar 3, 2017
利用网易股票数据接口下载上市公司股票价格数据
View cntrade.r
# cntrade R语言版
# 作者:陈堰平(新华指数有限责任公司,chen@yanping.me)
# 使用网易股票数据接口 原stata版的作者为:
# 李春涛(中南财经政法大学,chtl@znufe.edu.cn)
# 张璇(中南财经政法大学,zhangx@znufe.edu.cn)
# example:
# cntrade(c('600000', '000008'), path ='D:/stockprice', start = '20010104', end = '20120124')
cntrade <- function(tickers, path = "", start = "19910101", end = "") {
@yanping
yanping / readFudanData.r
Last active Dec 11, 2015
从复旦人民币汇率指数网站读取数据
View readFudanData.r
# 从复旦人民币汇率指数网站读取数据 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)
@yanping
yanping / readExchangeRate.r
Created Dec 27, 2012
Read Exchange Rate from the Federal Reserve Bank of New York
View readExchangeRate.r
# 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:/")
@yanping
yanping / shfePrice.r
Created Dec 6, 2012
获取上海期货交易所数据
View shfePrice.r
# 获取上海期货交易所数据
# 接口举例 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"
@yanping
yanping / zcePrice.r
Created Dec 6, 2012
读取郑州商品交易所数据
View zcePrice.r
# 读取郑州商品交易所数据
# 接口举例
# (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="")
@yanping
yanping / dcePrice.r
Created Dec 6, 2012
获取大商所期货数据
View dcePrice.r
# 从大连商品交易所网站抓取价格数据 数据源 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 : 聚乙烯
@yanping
yanping / index.html
Created Nov 20, 2012
博客首页异步加载分页
View index.html
<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>
You can’t perform that action at this time.