Technology moves fast! ⚡ Don't get left behind.🚶 Subscribe to our mailing list to keep up with latest and greatest in open source projects! 🏆


Subscribe to our mailing list

tushare

TuShare is a utility for crawling historical data of China stocks

Subscribe to updates I use tushare


Statistics on tushare

Number of watchers on Github 5167
Number of open issues 90
Average time to close an issue 8 days
Main language Python
Average time to merge a PR 8 days
Open pull requests 42+
Closed pull requests 14+
Last commit over 1 year ago
Repo Created over 4 years ago
Repo Last Updated over 1 year ago
Size 7.32 MB
Organization / Authorwaditu
Latest Release0.2.0
Contributors8
Page Updated
Do you use tushare? Leave a review!
View open issues (90)
View tushare activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating tushare for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

TuShare

TuShare/******** ****,

TuSharetushare

QQ

  • 14934432
  • 50658562506
  • 665480579

tushare

Dependencies

python 2.x/3.x

pandas

Installation

Upgrade

pip install tushare --upgrade

Quick Start

Example 1.

import tushare as ts

ts.get_hist_data('600848') #
get_k_data
   5102051020
             open    high   close     low     volume    p_change  ma5 \
date                                                                     
2012-01-11   6.880   7.380   7.060   6.880   14129.96     2.62   7.060   
2012-01-12   7.050   7.100   6.980   6.900    7895.19    -1.13   7.020   
2012-01-13   6.950   7.000   6.700   6.690    6611.87    -4.01   6.913   
2012-01-16   6.680   6.750   6.510   6.480    2941.63    -2.84   6.813   
2012-01-17   6.660   6.880   6.860   6.460    8642.57     5.38   6.822   
2012-01-18   7.000   7.300   6.890   6.880   13075.40     0.44   6.788   
2012-01-19   6.690   6.950   6.890   6.680    6117.32     0.00   6.770   
2012-01-20   6.870   7.080   7.010   6.870    6813.09     1.74   6.832 

             ma10    ma20      v_ma5     v_ma10     v_ma20     turnover  
date                                                                  
2012-01-11   7.060   7.060   14129.96   14129.96   14129.96     0.48  
2012-01-12   7.020   7.020   11012.58   11012.58   11012.58     0.27  
2012-01-13   6.913   6.913    9545.67    9545.67    9545.67     0.23  
2012-01-16   6.813   6.813    7894.66    7894.66    7894.66     0.10  
2012-01-17   6.822   6.822    8044.24    8044.24    8044.24     0.30  
2012-01-18   6.833   6.833    7833.33    8882.77    8882.77     0.45  
2012-01-19   6.841   6.841    7477.76    8487.71    8487.71     0.21  
2012-01-20   6.863   6.863    7518.00    8278.38    8278.38     0.23  



ts.get_hist_data('600848',start='2015-01-05',end='2015-01-09')

            open    high   close     low    volume   p_change     ma5    ma10 \  
date                                                                            
2015-01-05  11.160  11.390  11.260  10.890  46383.57     1.26  11.156  11.212   
2015-01-06  11.130  11.660  11.610  11.030  59199.93     3.11  11.182  11.155   
2015-01-07  11.580  11.990  11.920  11.480  86681.38     2.67  11.366  11.251   
2015-01-08  11.700  11.920  11.670  11.640  56845.71    -2.10  11.516  11.349   
2015-01-09  11.680  11.710  11.230  11.190  44851.56    -3.77  11.538  11.363   
            ma20     v_ma5    v_ma10     v_ma20      turnover  
date                                                        
2015-01-05  11.198  58648.75  68429.87   97141.81     1.59  
2015-01-06  11.382  54854.38  63401.05   98686.98     2.03  
2015-01-07  11.543  55049.74  61628.07  103010.58     2.97  
2015-01-08  11.647  57268.99  61376.00  105823.50     1.95  
2015-01-09  11.682  58792.43  60665.93  107924.27     1.54  

ts.get_h_data('002337') #
ts.get_h_data('002337',autype='hfq') #
ts.get_h_data('002337',autype=None) #
ts.get_h_data('002337',start='2015-01-01',end='2015-03-16') #

Example 2.

ts.get_today_all()
      code    name     changepercent  trade   open   high    low  settlement \  
0     002738           10.023  19.32  19.32  19.32  19.32       17.56   
1     300410           10.022  25.03  25.03  25.03  25.03       22.75   
2     002736           10.013  16.37  16.37  16.37  16.37       14.88   
3     300412           10.010  31.54  31.54  31.54  31.54       28.67   
4     300411           10.007  29.68  29.68  29.68  29.68       26.98   
5     603636           10.006  38.15  38.15  38.15  38.15       34.68   
6     002664           10.004  30.68  29.00  30.68  28.30       27.89   
7     300367           10.004  86.76  78.00  86.76  77.87       78.87   
8     601299           10.000  11.44  11.44  11.44  11.29       10.40   
9     601880            10.000   5.72   5.34   5.72   5.22        5.20   
10    000856           10.000   8.91   8.18   8.91   8.18        8.10  
        volume       turnoverratio  
0        375100        1.25033  
1         85800        0.57200  
2       1058925        0.08824  
3         69400        0.51791  
4        252220        1.26110  
5       1374630        5.49852  
6       6448748        9.32700  
7       2025030        6.88669  
8     433453523        4.28056  
9     323469835        9.61735  
10     25768152       19.51090  

Example 3.

import tushare as ts

df = ts.get_tick_data('600848',date='2014-01-09')
df.head(10)

()

Out[3]: 
     time       price change  volume  amount  type
0    15:00:00   6.05     --       8    4840   
1    14:59:55   6.05     --      50   30250   
2    14:59:35   6.05     --      20   12100   
3    14:59:30   6.05  -0.01     165   99825   
4    14:59:20   6.06   0.01       4    2424   
5    14:59:05   6.05  -0.01       2    1210   
6    14:58:55   6.06     --       4    2424   
7    14:58:45   6.06     --       2    1212   
8    14:58:35   6.06   0.01       2    1212   
9    14:58:25   6.05  -0.01      20   12100   
10   14:58:05   6.06     --       5    3030   

Example 4. (Realtime Quotes Data)

df = ts.get_realtime_quotes('000581') #Single stock symbol
df[['code','name','price','bid','ask','volume','amount','time']]

...more in docs

   code    name     price  bid    ask    volume   amount        time
0  000581    31.15  31.14  31.15  8183020  253494991.16  11:30:36 

30

ts.get_realtime_quotes(['600848','000980','000981']) #symbols from a list
ts.get_realtime_quotes(df['code'].tail(10)) #from a Series

======== http://tushare.org/

Change Logs

1.0.5 2017/11/12

-

  • bug

1.0.2 2017/10/29

  • barETF

- tick

  • bug

0.9.2 2017/09/13

  • ,okcoin
  • bug

0.8.8 2017/08/29

  • get_day_all
  • BDI

0.8.0 2017/06/05

  • 6debugo
  • bug

0.7.6 2017/05/16

  • get_today_all
  • forecast_data mac

0.7.0 2017/03/12

- get_today_all

0.6.2 2016/12/03

  • top10_holders
  • global_realtime
  • bug

0.6.1 2016/11/22

- get_k_databug

0.5.6 2016/11/06

  • get_k_data(tushare)
  • bug

0.5.1 2016/10/16

  • bug

0.4.9 2016/03/26

  • get_industry_classified(standard='sw')
  • trade_cal()
  • bug

0.4.3 2015/12/24

  • bug

0.4.1 2015/11/27

  • sina

- bug

0.3.9 2015/10/13

-

0.3.8 2015/09/19

  • 300
  • bug

0.3.5 2015/07/27

0.3.4 2015/06/15

  • get_h_datafloat

  • get_indexopen

  • GitHubbug

0.2.8 2015/04/28

-

-

  • get_h_databug

0.2.6

-

-

  • null300

0.2.5 2015/04/16

- python2.xpython3.x

- 500

  • bug

0.2.3 2015/04/11

-

  • columnbug

0.2.0 2015/03/17

  • 300
  • 50
  • float

0.1.9 2015/02/06

-

0.1.6 2015/01/27

  • docs

0.1.5 2015/01/26

0.1.3 2015/01/13

  • Done for crawling Realtime Quotes data

0.1.1 2015/01/11

  • tick

0.1.0 2014/12/01

-

tushare open issues Ask a question     (View All Issues)
  • over 2 years 获取停牌股票列表?
  • over 2 years 可以本地数据库提供数据源吗
  • over 2 years 历史数据获取不全
  • over 2 years 历史分笔数据都是除权的,有什么办法可以转化成前复权数据
  • over 2 years 分钟级别数据获取错误
  • over 2 years 历史行情 get_hist_data 不能获取深圳A股2016年11月份的数据,只能获取到10月份前的
  • over 2 years 多线程下get_h_data报错,pointer being freed was not allocated
  • over 2 years 'float' object has no attribute 'replace'
  • over 2 years 某些股票get_h_data()复权日左右数据计算错误
  • over 2 years 哪里可以获得历史新闻,就像获得即时新闻那样
  • over 2 years 是不是ifeng的源不好用了?
  • over 2 years Anaconda 安装不上tushare
  • over 2 years 每个季度的第一个交易日,用get_h_data(设置index=True)会报错
  • over 2 years 实时行情 缺失
  • over 2 years 最近服务器老是time out?
  • almost 3 years 是不是可以多找两个 contributor 协助维护项目?
  • almost 3 years 股票历史数据不准确
  • almost 3 years 所有股票2016.8.29历史分笔数据缺失
  • almost 3 years forecast_data接口对应的数据源发生变化了
  • almost 3 years 大盘实时行情,能不能直接把实时指数加上,涨跌幅精度不够,推算出来的实时指数不够精确
  • almost 3 years 建议增加基本面数据----财务三大表数据
  • almost 3 years get_sina_dd volume数据是不是缺少小数点
  • almost 3 years ts.get_sina_dd 可能缺失记录
  • almost 3 years get_today_all无法获取数据,建议添加获取某日全部股票数据接口get_date_all
  • almost 3 years 关于数据源
  • almost 3 years 建议更改:行情数据返回值的index的类型
  • almost 3 years 数据重复
  • almost 3 years df.sort方法产生了一个警告
  • almost 3 years 基本面数据股票列表中的PE值异常(网络数据源头问题)
  • almost 3 years get_latest_news(): Error reading content - failed to load HTTP resource
tushare open pull requests (View All Pulls)
  • Include tushare.internet in setup.py
  • trading.py: fix get_today_ticks()
  • 添加函数获取业绩报告披露时间
  • 当获取后复权、不复权数据时,返回复权因子
  • get_today_ticks 会漏掉第一页的数据,现修复
  • Fix new_stocks() not working
  • ENH: 1. add more index-code mapping so that get_hist_data() works for more indexes; 2. INDEX_LABELS now depends on INDEX_LIST; 3. name '中证'index as 'zz' instead of 'zh'.
  • DataFrame.sort is DEPRECATED, using sort_values instead
  • 解决sort is deprecated #70问题
  • 修改了没有日内tick数据时返回的dateframe错误,现返回None
  • Update trading.py
  • fix bug of is_holiday
  • _code_to_symbol函数改进
  • 增加基金数据获取相关接口
  • Merge pull request #1 from waditu/master
  • Update fundamental.rst
  • 修改fundamental.py中的函数,增加排序功能
  • Update cons.py
  • Merge pull request #1 from waditu/master
  • DataFrame.sort方法替换 适用于pandas v0.17.0版本以及之后
  • 修改实盘交易登陆网址 url:newetradesh.csc108.com
  • 1.增加个股龙虎榜
  • 添加3个新函数(可获取指定股票公司历史所有的财务报表数据)
  • 修改 setup.py 添加 install_requires
  • A sub-package for processing data from the investor relationship platforms
  • 修复get_k_data获取不到当天数据的问题
  • get_report_data: REPORT_URL add `order` parameter
  • fix issue #380,新股吧这个问题是因为新股吧页面中加了广告
  • 删除重复的intoDate查询字符串参数
  • 获取东方财富网数据中心股东增减持数据
  • Update trading.rst
  • get_notices(),通过soup进行内容解析,取代lxmll方法
  • Use Unicode literals to simplify the logic
  • merge
  • get_concept_classified 接口太快会被封掉,现在设默认参数为10s,并可以手动输入参数
  • 所有网路请求可以使用代理使用方法:
  • null obj protection and one unsolved issue
  • 设置了user-agent,修复pip install时的依赖问题
  • shibor encoding issue under Python3
  • 文档字条串错字修正
  • fix #249
  • 修正一个python2/3运行过程中的过期函数keyword问题
tushare list of languages used
Other projects in Python