tushare-finance
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTushare 金融数据 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?
如未配置,引导用户:
- 访问 https://tushare.pro 注册
- 获取 Token
- 配置环境变量:
export TUSHARE_TOKEN="your_token"
Ask the user: Have you configured your Tushare Token?
If not configured, guide the user:
- Visit https://tushare.pro to register
- Obtain the Token
- 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 pandasCheck 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
| 数据类型 | 接口方法 | 说明 |
|---|---|---|
| 股票列表 | | 获取所有股票列表 |
| 日线行情 | | 获取日线行情数据 |
| 财务指标 | | 财务指标(ROE等) |
| 利润表 | | 利润表数据 |
| 指数行情 | | 指数日线数据 |
| 基金净值 | | 基金净值数据 |
| GDP数据 | | 国内生产总值 |
| CPI数据 | | 居民消费价格指数 |
完整接口列表:查看 接口文档索引
| Data Type | Interface Method | Description |
|---|---|---|
| Stock List | | Retrieve all stock lists |
| Daily Quotes | | Retrieve daily quote data |
| Financial Indicators | | Financial indicators (ROE, etc.) |
| Income Statement | | Income statement data |
| Index Quotes | | Daily index data |
| Fund Net Value | | Fund net value data |
| GDP Data | | Gross Domestic Product |
| CPI Data | | Consumer Price Index |
Complete Interface List: View Interface Document Index
数据获取流程
Data Retrieval Process
- 查找接口:根据需求在 接口索引 找到对应接口
- 阅读文档:查看 了解参数
reference/接口文档/[接口名].md - 编写代码:
python
import tushare as ts # 初始化(使用环境变量中的 Token) pro = ts.pro_api() # 调用接口 df = pro.daily(ts_code='000001.SZ', start_date='20241201', end_date='20241231') - 返回结果:DataFrame 格式
- Find the Interface: Locate the corresponding interface in the Interface Index based on requirements
- Read the Documentation: Check to understand parameters
reference/接口文档/[接口名].md - 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') - 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
- Tushare 官方文档:https://tushare.pro/document/2
- API 测试工具:https://tushare.pro/document/1
- Tushare Official Documentation: https://tushare.pro/document/2
- API Testing Tool: https://tushare.pro/document/1