← Back to Skills Marketplace
wangzhaofeng-max

Tushare 金融数据助手

by wangzhaofeng-max · GitHub ↗ · v1.2.0 · MIT-0
cross-platform ✓ Security Clean
70
Downloads
0
Stars
0
Active Installs
3
Versions
Install in OpenClaw
/install tushare-finance-pro
Description
Tushare Pro 金融数据接口 - A股/港股/美股/基金/期货/债券/宏观经济,220+数据接口,支持财务报表、估值分析、行业研究
README (SKILL.md)

Tushare Pro 金融数据助手

功能特性

  • 股票行情查询(自动重试机制)
  • 基础财务数据
  • 宏观经济数据
  • 全量 220+ 接口
  • 自动财务报表
  • DCF 估值模型
  • 行业对比分析
  • 定时数据推送
  • 智能错误处理
  • Token 验证

快速开始

pip install tushare pandas
export TUSHARE_TOKEN="your_token"

股票行情

import tushare as ts

pro = ts.pro_api()

# 日线行情
df = pro.daily(ts_code='000001.SZ', start_date='20240101', end_date='20241231')

# 周线行情
df = pro.weekly(ts_code='000001.SZ')

# 月线行情
df = pro.monthly(ts_code='000001.SZ')

基础财务

# 财务指标
df = pro.fina_indicator(ts_code='000001.SZ')

# 利润表
df = pro.income(ts_code='000001.SZ')

# 资产负债表
df = pro.balancesheet(ts_code='000001.SZ')

# 现金流量表
df = pro.cashflow(ts_code='000001.SZ')

宏观经济

# GDP
df = pro.gdp()

# CPI
df = pro.cpi()

# PMI
df = pro.pmi()

# 货币供应
df = pro.m2()

自动财务报表生成

def generate_financial_report(ts_code):
    """生成完整财务报表"""
    report = {}
    
    # 基本信息
    info = pro.stock_basic(ts_code=ts_code, fields='ts_code,name,industry,market')
    report['info'] = info.iloc[0].to_dict()
    
    # 财务指标
    indicator = pro.fina_indicator(ts_code=ts_code, period='20231231')
    report['indicator'] = indicator.iloc[0].to_dict() if not indicator.empty else {}
    
    # 利润表
    income = pro.income(ts_code=ts_code, period='20231231')
    report['income'] = income.iloc[0].to_dict() if not income.empty else {}
    
    # 资产负债表
    balance = pro.balancesheet(ts_code=ts_code, period='20231231')
    report['balance'] = balance.iloc[0].to_dict() if not balance.empty else {}
    
    return report

DCF 估值模型

def dcf_valuation(ts_code, growth_rate=0.15, wacc=0.1, terminal_growth=0.03):
    """DCF 估值模型"""
    # 获取历史财务数据
    income = pro.income(ts_code=ts_code)
    
    if income.empty:
        return None
    
    latest = income.iloc[0]
    base_revenue = latest.get('revenue', 0)
    net_margin = latest.get('net_profit', 0) / base_revenue if base_revenue > 0 else 0
    
    # 预测未来5年现金流
    cash_flows = []
    for year in range(1, 6):
        revenue = base_revenue * (1 + growth_rate) ** year
        net_profit = revenue * net_margin
        cash_flows.append(net_profit)
    
    # 计算终值
    terminal_value = cash_flows[-1] * (1 + terminal_growth) / (wacc - terminal_growth)
    
    # 折现
    pv_sum = sum(cf / (1 + wacc) ** i for i, cf in enumerate(cash_flows, 1))
    pv_terminal = terminal_value / (1 + wacc) ** 5
    
    total_value = pv_sum + pv_terminal
    
    return {
        'company_value': total_value,
        'cash_flows': cash_flows,
        'terminal_value': terminal_value,
        'assumptions': {
            'growth_rate': growth_rate,
            'wacc': wacc,
            'terminal_growth': terminal_growth,
            'net_margin': net_margin
        }
    }

行业对比分析

def industry_comparison(industry, top_n=10):
    """行业对比分析"""
    # 获取行业股票列表
    stocks = pro.stock_basic(industry=industry, list_status='L', 
                            fields='ts_code,name,market_cap')
    
    if stocks.empty:
        return None
    
    # 按市值排序
    stocks = stocks.sort_values('market_cap', ascending=False).head(top_n)
    
    results = []
    for _, stock in stocks.iterrows():
        try:
            indicator = pro.fina_indicator(ts_code=stock['ts_code'], period='20231231')
            if not indicator.empty:
                results.append({
                    'ts_code': stock['ts_code'],
                    'name': stock['name'],
                    'market_cap': stock['market_cap'],
                    'roe': indicator.iloc[0].get('roe', None),
                    'net_profit_margin': indicator.iloc[0].get('netprofit_margin', None),
                    'revenue_growth': indicator.iloc[0].get('or_yoy', None)
                })
        except:
            continue
    
    return pd.DataFrame(results)

定时数据推送

在 OpenClaw 配置定时任务:

{
  "cron": {
    "jobs": [
      {
        "id": "daily-market",
        "schedule": "0 16 * * 1-5",
        "prompt": "生成今日A股市场日报",
        "channel": "feishu"
      },
      {
        "id": "weekly-report",
        "schedule": "0 9 * * 1",
        "prompt": "生成本周行业研究报告",
        "channel": "feishu"
      }
    ]
  }
}

接口速查表

类别 接口数 常用接口
股票数据 39 daily, weekly, monthly, stock_basic
指数数据 18 index_daily, index_weight
基金数据 11 fund_nav, fund_daily
期货期权 16 fut_daily, opt_daily
宏观经济 10 gdp, cpi, pmi, m2
港股美股 23 hk_daily, us_daily
债券数据 16 bond_daily, bond_cov

配置说明

  1. 注册 Tushare Pro: https://tushare.pro
  2. 获取 API Token
  3. 设置环境变量: export TUSHARE_TOKEN="your_token"

风险提示

  1. 数据来源: Tushare Pro,需遵守使用协议
  2. 数据延迟: 部分数据有 15 分钟延迟
  3. 投资风险: 数据仅供参考,不构成投资建议
Usage Guidance
Install only if you are comfortable giving the skill access to your Tushare API token and making outbound financial-data requests. Prefer setting the token only for the current session or through a secret manager, avoid committing config files containing the token, and do not run the helper test in shared logs unless the token-printing line is removed.
Capability Tags
crypto
Capability Assessment
Purpose & Capability
The artifacts consistently describe a financial market data skill for Tushare Pro, with Python helpers for querying public market, financial statement, macroeconomic, fund, futures, and related datasets.
Instruction Scope
Runtime behavior is mostly user-directed API querying and optional export; documentation also includes optional scheduled reporting examples, but no artifact shows hidden or automatic scheduling on install.
Install Mechanism
Installation is standard Python package installation for tushare and pandas, but requirements use lower-bound dependency versions instead of pinned versions.
Credentials
Network access and a TUSHARE_TOKEN are proportionate for a Tushare integration; crawler-backed reference docs disclose that some realtime endpoints use third-party data sources outside Tushare servers.
Persistence & Privilege
The skill does not install persistence or request elevated privileges, but the README suggests storing the token in ~/.bashrc or config/config.yaml and one helper test prints the first 10 token characters locally.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install tushare-finance-pro
  3. After installation, invoke the skill by name or use /tushare-finance-pro
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.2.0
Version 1.2.0 introduces improved reliability and robustness with enhanced error handling and token validation. - Added helper script `tushare_helper.py` to facilitate automatic retries and error handling. - Updated documentation to highlight new features: retry mechanism, intelligent error handling, and token validation. - Removed outdated `skill-card.md` file.
v1.1.0
- 移除了 Pro 版与免费版对比表,统一功能说明,使文档更简洁。 - 删去了付费价格和联系方式信息,去除了 Pro 版价格相关描述。 - 简化元数据,删除 tier 和 price 字段,统一依赖说明。 - 保留并精炼了所有主要功能、用法示例与配置说明,避免冗余。 - 改进整体结构,提高易读性。
v1.0.0
Initial release: Comprehensive Tushare Pro financial data toolkit. - Provides A股/港股/美股/基金/期货/债券及宏观经济等220+数据接口 - 支持免费基础行情、财务、宏观经济数据,Pro版额外提供自动报表、估值模型及行业分析等 - 详细使用示例涵盖行情、财务、宏观经济、自动报表、DCF估值、行业对比 - 支持定时推送及多种安装配置说明 - 价格方案与权益对比清晰明了
Metadata
Slug tushare-finance-pro
Version 1.2.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 3
Frequently Asked Questions

What is Tushare 金融数据助手?

Tushare Pro 金融数据接口 - A股/港股/美股/基金/期货/债券/宏观经济,220+数据接口,支持财务报表、估值分析、行业研究. It is an AI Agent Skill for Claude Code / OpenClaw, with 70 downloads so far.

How do I install Tushare 金融数据助手?

Run "/install tushare-finance-pro" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Tushare 金融数据助手 free?

Yes, Tushare 金融数据助手 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Tushare 金融数据助手 support?

Tushare 金融数据助手 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Tushare 金融数据助手?

It is built and maintained by wangzhaofeng-max (@wangzhaofeng-max); the current version is v1.2.0.

💬 Comments