tushare-finance

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Tushare 金融数据 Skill

Tushare Financial Data Skill

本 skill 通过 Tushare Pro API 获取中国金融市场数据,支持 220+ 个数据接口。
This skill retrieves Chinese financial market data via the Tushare Pro API, supporting over 220 data interfaces.

快速开始

Quick Start

1. Token 配置

1. Token Configuration

询问用户:是否已配置 Tushare Token?
如未配置,引导用户:
  1. 访问 https://tushare.pro 注册
  2. 获取 Token
  3. 配置环境变量:
    export TUSHARE_TOKEN="your_token"
Ask the user: Have you configured your Tushare Token?
If not configured, guide the user:
  1. Visit https://tushare.pro to register
  2. Obtain the Token
  3. Configure the environment variable:
    export TUSHARE_TOKEN="your_token"

2. 验证依赖

2. Verify Dependencies

检查 Python 环境:
bash
python -c "import tushare, pandas; print('OK')"
如报错,安装依赖:
bash
pip install tushare pandas
Check the Python environment:
bash
python -c "import tushare, pandas; print('OK')"
If an error occurs, install dependencies:
bash
pip install tushare pandas

常用接口速查

Quick Reference for Common Interfaces

数据类型接口方法说明
股票列表
pro.stock_basic()
获取所有股票列表
日线行情
pro.daily()
获取日线行情数据
财务指标
pro.fina_indicator()
财务指标(ROE等)
利润表
pro.income()
利润表数据
指数行情
pro.index_daily()
指数日线数据
基金净值
pro.fund_nav()
基金净值数据
GDP数据
pro.gdp()
国内生产总值
CPI数据
pro.cpi()
居民消费价格指数
完整接口列表:查看 接口文档索引
Data TypeInterface MethodDescription
Stock List
pro.stock_basic()
Retrieve all stock lists
Daily Quotes
pro.daily()
Retrieve daily quote data
Financial Indicators
pro.fina_indicator()
Financial indicators (ROE, etc.)
Income Statement
pro.income()
Income statement data
Index Quotes
pro.index_daily()
Daily index data
Fund Net Value
pro.fund_nav()
Fund net value data
GDP Data
pro.gdp()
Gross Domestic Product
CPI Data
pro.cpi()
Consumer Price Index
Complete Interface List: View Interface Document Index

数据获取流程

Data Retrieval Process

  1. 查找接口:根据需求在 接口索引 找到对应接口
  2. 阅读文档:查看
    reference/接口文档/[接口名].md
    了解参数
  3. 编写代码
    python
    import tushare as ts
    
    # 初始化(使用环境变量中的 Token)
    pro = ts.pro_api()
    
    # 调用接口
    df = pro.daily(ts_code='000001.SZ', start_date='20241201', end_date='20241231')
  4. 返回结果:DataFrame 格式
  1. Find the Interface: Locate the corresponding interface in the Interface Index based on requirements
  2. Read the Documentation: Check
    reference/接口文档/[接口名].md
    to understand parameters
  3. Write Code:
    python
    import tushare as ts
    
    # Initialize (using Token from environment variables)
    pro = ts.pro_api()
    
    # Call the interface
    df = pro.daily(ts_code='000001.SZ', start_date='20241201', end_date='20241231')
  4. Return Result: In pandas DataFrame format

参数格式说明

Parameter Format Description

  • 日期:YYYYMMDD(如 20241231)
  • 股票代码:ts_code 格式(如 000001.SZ, 600000.SH)
  • 返回格式:pandas DataFrame
  • Date: YYYYMMDD (e.g., 20241231)
  • Stock Code: ts_code format (e.g., 000001.SZ, 600000.SH)
  • Return Format: pandas DataFrame

接口文档参考

Interface Document Reference

接口索引reference/README.md
接口文档按类别组织:
  • 股票数据(39 个接口)
  • 指数数据(18 个接口)
  • 基金数据(11 个接口)
  • 期货期权(16 个接口)
  • 宏观经济(10 个接口)
  • 港股美股(23 个接口)
  • 债券数据(16 个接口)
Interface Index: reference/README.md
Interface documents are organized by category:
  • Stock Data (39 interfaces)
  • Index Data (18 interfaces)
  • Fund Data (11 interfaces)
  • Futures & Options (16 interfaces)
  • Macroeconomics (10 interfaces)
  • Hong Kong & US Stocks (23 interfaces)
  • Bond Data (16 interfaces)

参考资源

Reference Resources