Skip to content

jincheng9/stock_crawler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 

Repository files navigation

A very simple R API for retrieving real time China's A-share stock and index data from sina finance.

Prerequisite

  1. install.packages('RCurl')
  2. library(RCurl)

Usage

  1. Download the R file
  2. Source('get.stock.index.info.R')

API to retrieve stock information: get.stock.info

## Default S3 method:
get.stock.info(stock.code)

## Arguments
stock.code     a string of the stock code 
               浦发银行"sh600000" 平安银行"sz000001"
## return value: a data.frame with 32 variables
1: "大秦铁路",股票名字;
227.55,今日开盘价;
327.25,昨日收盘价;
426.91,当前价格;
527.55,今日最高价;
626.20,今日最低价;
726.91,竞买价,即“买一”报价;
826.92,竞卖价,即“卖一”报价;
922114263,成交的股票数,由于股票交易以一百股为基本单位,所以在使用时,通常把该值除以一百;
10589824680,成交金额,单位为“元”,为了一目了然,通常以“万元”为成交金额的单位,所以通常把该值除以一万;
114695,“买一”申请4695股,即47手;
1226.91,“买一”报价;
1357590,“买二”
1426.90,“买二”
1514700,“买三”
1626.89,“买三”
1714300,“买四”
1826.88,“买四”
1915100,“买五”
2026.87,“买五”
213100,“卖一”申报3100股,即31手;
2226.92,“卖一”报价
(23, 24), (25, 26), (27,28), (29, 30)分别为“卖二”至“卖四的情况”
31"2008-01-11",日期;
32"15:05:32",时间;

## sample code
stock.data <- get.stock.info('sh600000')
cat('stock symbol is: ', stock.data$V1, '\n')
cat('open price is: ', stock.data$V2, '\n')
cat('previous close price is: ', stock.data$V3, '\n')			   
cat('current price is: ', stock.data$V4, '\n')			   

API to retrieve index information: get.index.info

## Default S3 method:
get.index.info(index.code)

## Arguments
index.code     a string of the index code 
               上证指数"sh000001"
			   深圳成指"sz399001"
## return value: a data.frame with 6 variables
1: "上证指数", 指数名称
2: 5484.677, 当前点数
3: 28.136, 当前价格
4: 0.52, 涨跌率
5: 877247, 成交量(手)
6: 15587495, 成交额(万元)

# sample code
index.data <- get.index.info('sz399905')
cat('index symbol is: ', index.data$V1, '\n')		   
cat('current price is: ', index.data$V3, '\n')	

Reference for crawling China's A-share and HK share:

http://www.cnblogs.com/yunzi/p/3213022.html

http://wenku.baidu.com/view/8907c542b307e87101f6962b.html

About

R API for Crawling Stock and Index Data from Sina Finance

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages