Skip to main content

tushare

Tushare Pro 金融大数据平台 - 提供A股、指数、基金、期货、债券、宏观数据,Token认证方式访问。

Source facts

Repository
LeoYeAI/openclaw-master-skills
Last source activity
July 20, 2026 at 02:05
Detected SKILL.md language
Mixed languages
Stars
2,151
Forks
325

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

File Explorer
8 files

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
tushare
description
Tushare Pro 金融大数据平台 - 提供A股、指数、基金、期货、债券、宏观数据,Token认证方式访问。
version
1.2.0
homepage
https://tushare.pro
metadata
{"clawdbot":{"emoji":"📉","requires":{"bins":"[Truncated]"}}}
# Tushare Pro(大数据开放社区) [Tushare Pro](https://tushare.pro) is a widely used financial data platform in China, serving over 300,000 users. It provides a standardized Python API covering A-shares, indices, funds, futures, bonds, and macro data. All interfaces return `pandas.DataFrame`. > ⚠️ **Token Required**: Register at https://tushare.pro and obtain your personal Token from the User Center. Some interfaces require a higher credit level. See the Credit System section below. ## 安装 ```bash pip install tushare --upgrade ``` ## 初始化与基本用法 ```python import tushare as ts # Set Token (only needs to be set once per session) ts.set_token('your_token_here') # Initialize the Pro API pro = ts.pro_api() # Call any data interface df = pro.daily(ts_code='000001.SZ', start_date='20240101', end_date='20240630') print(df) ``` You can also pass the Token directly during initialization: ```python # Initialize with Token directly pro = ts.pro_api('your_token_here') ``` ## 股票代码格式(ts_code) - Shanghai: `600000.SH`, `601398.SH` - Shenzhen: `000001.SZ`, `300750.SZ` - Beijing: `430047.BJ` - Indices: `000001.SH` (SSE Composite Index), `399001.SZ` (SZSE Component Index) --- ## 沪深股票数据 ### 股票列表 ```python # Get basic information for all currently listed stocks df = pro.stock_basic( exchange='', list_status='L', # L=Listed, D=Delisted, P=Suspended fields='ts_code,symbol,name,area,industry,list_date' ) ``` Credit requirement: 120 ### 日K线数据 ```python # Get daily market data for a specified stock df = pro.daily( ts_code='000001.SZ', start_date='20240101', end_date='20240630' ) # Returned fields: ts_code, trade_date, open, high, low, close, pre_close, change, pct_chg, vol, amount ``` Credit requirement: 120 ### 周线/月线数据 ```python # Get weekly data df = pro.weekly(ts_code='000001.SZ', start_date='20240101', end_date='20240630') # Get monthly data df = pro.monthly(ts_code='000001.SZ', start_date='20240101', end_date='20240630') ``` ### 分钟级K线数据 ```python # Get minute-level K-line data df = pro.stk_mins( ts_code='000001.SZ', freq='5min', # Options: 1min, 5min, 15min, 30min, 60min start_date='2024-01-02 09:30:00', end_date='2024-01-02 15:00:00' ) ``` Credit requirement: 2000+ ### 复权因子 ```python # Get adjustment factors for calculating forward/backward adjusted prices df = pro.adj_factor(ts_code='000001.SZ', trade_date='20240102') ``` ### 每日指标 ```python # Get daily market indicator data (PE ratio, PB ratio, turnover rate, market cap, etc.) df = pro.daily_basic( ts_code='000001.SZ', trade_date='20240102', fields='ts_code,trade_date,turnover_rate,volume_ratio,pe,pe_ttm,pb,ps,ps_ttm,dv_ratio,dv_ttm,total_mv,circ_mv' ) ``` Credit requirement: 120 ### 停复牌信息 ```python # Get suspension & resumption info, S=Suspended df = pro.suspend_d(ts_code='000001.SZ', suspend_type='S') ``` --- ## 财务数据 ### 利润表 ```python # Get listed company income statement data df = pro.income(ts_code='000001.SZ', period='20231231') ``` ### 资产负债表 ```python # Get listed company balance sheet data df = pro.balancesheet(ts_code='000001.SZ', period='20231231') ``` ### 现金流量表 ```python # Get listed company cash flow statement data df = pro.cashflow(ts_code='000001.SZ', period='20231231') ``` ### 财务指标 ```python # Get financial indicator data (ROE, EPS, revenue growth rate, net profit growth rate, etc.) df = pro.fina_indicator(ts_code='000001.SZ', period='20231231') ``` ### 业绩预告 ```python # Get listed company earnings forecast data df = pro.forecast(ts_code='000001.SZ', period='20231231') ``` ### 业绩快报 ```python # Get listed company earnings express report data df = pro.express(ts_code='000001.SZ', period='20231231') ``` ### 分红送股 ```python # Get listed company dividend and share distribution data df = pro.dividend(ts_code='000001.SZ') ``` --- ## 市场参考数据 ### 个股资金流向 ```python # Get individual stock money flow data df = pro.moneyflow(ts_code='000001.SZ', start_date='20240101', end_date='20240630') ``` Credit requirement: 2000+ ### 龙虎榜 ```python # 获取龙虎榜数据 df = pro.top_list(trade_date='20240102') ``` ### 大宗交易 ```python # Get block trade data df = pro.block_trade(ts_code='000001.SZ', start_date='20240101', end_date='20240630') ``` ### 融资融券 ```python # Get margin trading detail data df = pro.margin_detail(trade_date='20240102') ``` ### 股东增减持 ```python # Get shareholder increase/decrease in holdings data df = pro.stk_holdertrade(ts_code='000001.SZ', start_date='20240101', end_date='20240630') ``` --- ## 指数数据 ### 指数日K线 ```python # Get index daily market data df = pro.index_daily(ts_code='000300.SH', start_date='20240101', end_date='20240630') ``` ### 指数成分股 ```python # Get index constituents and weights df = pro.index_weight(index_code='000300.SH', start_date='20240101', end_date='20240630') ``` ### 指数基本信息 ```python # Get index basic information; market options: SSE (Shanghai Stock Exchange), SZSE (Shenzhen Stock Exchange), etc. df = pro.index_basic(market='SSE') ``` --- ## 基金数据 ### 基金列表 ```python # Get fund list; E=Exchange-traded, O=OTC (over-the-counter) df = pro.fund_basic(market='E') ``` ### 基金日行情 ```python # Get exchange-traded fund daily market data df = pro.fund_daily(ts_code='510300.SH', start_date='20240101', end_date='20240630') ``` ### 基金净值 ```python # Get OTC fund net asset value data df = pro.fund_nav(ts_code='000001.OF') ``` --- ## 期货数据 ### 期货日行情 ```python # Get futures daily market data df = pro.fut_daily(ts_code='IF2401.CFX', start_date='20240101', end_date='20240131') ``` ### 期货基本信息 ```python # Get futures contract basic information # exchange options: CFFEX (China Financial Futures Exchange), SHFE (Shanghai Futures Exchange), DCE (Dalian Commodity Exchange), CZCE (Zhengzhou Commodity Exchange), INE (Shanghai International Energy Exchange) df = pro.fut_basic(exchange='CFFEX', fut_type='1') ``` --- ## 债券数据 ### 可转债列表 ```python # Get convertible bond basic information df = pro.cb_basic() ``` ### 可转债日行情 ```python # Get convertible bond daily market data df = pro.cb_daily(ts_code='113009.SH', start_date='20240101', end_date='20240630') ``` --- ## 宏观经济数据 ### Shibor利率 ```python # Get Shanghai Interbank Offered Rate df = pro.shibor(start_date='20240101', end_date='20240630') ``` ### GDP(国内生产总值) ```python # Get China GDP data df = pro.cn_gdp() ``` ### CPI(居民消费价格指数) ```python # Get China Consumer Price Index df = pro.cn_cpi(start_m='202401', end_m='202406') ``` ### PPI(生产者物价指数) ```python # Get China Producer Price Index df = pro.cn_ppi(start_m='202401', end_m='202406') ``` ### 货币供应量 ```python # Get China money supply data (M0, M1, M2) df = pro.cn_m(start_m='202401', end_m='202406') ``` --- ## 交易日历 ```python # Get trading calendar df = pro.trade_cal( exchange='SSE', # Exchange: SSE (Shanghai), SZSE (Shenzhen), BSE (Beijing) start_date='20240101', end_date='20241231', fields='exchange,cal_date,is_open,pretrade_date' ) ``` --- ## 完整示例:下载股票数据并保存为CSV ```python import tushare as ts import pandas as pd ts.set_token('your_token_here') pro = ts.pro_api() # Get Kweichow Moutai daily K-line data df = pro.daily(ts_code='600519.SH', start_date='20240101', end_date='20241231') # Get adjustment factors and calculate forward-adjusted closing price adj = pro.adj_factor(ts_code='600519.SH', start_date='20240101', end_date='20241231') df = df.merge(adj[['trade_date', 'adj_factor']], on='trade_date') df['adj_close'] = df['close'] * df['adj_factor'] # Calculate forward-adjusted price # Save as CSV file df.to_csv('moutai_2024.csv', index=False) print(df.head()) ``` ## 积分系统 | 等级 | 积分 | 可用接口示例 | |---|---|---| | **基础** | 120 | `stock_basic`, `daily`, `weekly`, `monthly`, `trade_cal`, `daily_basic` | | **中级** | 2000 | `stk_mins`(分钟数据), `moneyflow`, `margin_detail`, `fina_indicator` | | **高级** | 5000+ | Tick数据、大单数据、更高频率限制 | ### 如何免费获取积分 1. 注册并完善个人信息 → 获得120积分 2. 每日在tushare.pro签到 3. 社区贡献(分享、回答问题) 4. 邀请好友注册 ## 使用技巧 - **需要Token** — 在 https://tushare.pro 免费注册获取(用户中心)。 - **日期格式**:`YYYYMMDD`(无连字符),所有日期参数使用此格式。 - **ts_code格式**:`{code}.{exchange}` — 如 `000001.SZ`、`600519.SH`。 - 所有接口返回 **pandas DataFrame**。 - 频率限制取决于积分等级 — 积分越高,每分钟调用次数越多。 - 使用 `fields` 参数仅选择需要的字段,提升查询性能。 - 本地缓存参考数据(股票列表、交易日历)以避免重复调用。 - Documentation: https://tushare.pro/document/2 --- ## 进阶示例 ### 批量下载多只股票 ```python import tushare as ts import pandas as pd import time ts.set_token('your_token_here') pro = ts.pro_api() # 定义要下载的股票列表 stock_list = ['000001.SZ', '600519.SH', '300750.SZ', '601318.SH', '000858.SZ'] all_data = [] for ts_code in stock_list: # Get daily K-line data df = pro.daily(ts_code=ts_code, start_date='20240101', end_date='20240630') all_data.append(df)
View on GitHub
This SKILL.md is very large, so SkillsMP previews the first section here. View on GitHub