← 返回 Skills 市场
wangzhaofeng-max

Tushare 金融数据助手

作者 wangzhaofeng-max · GitHub ↗ · v1.2.0 · MIT-0
cross-platform ✓ 安全检测通过
70
总下载
0
收藏
0
当前安装
3
版本数
在 OpenClaw 中安装
/install tushare-finance-pro
功能描述
Tushare Pro 金融数据接口 - A股/港股/美股/基金/期货/债券/宏观经济,220+数据接口,支持财务报表、估值分析、行业研究
使用说明 (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. 投资风险: 数据仅供参考,不构成投资建议
安全使用建议
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.
能力标签
crypto
能力评估
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.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install tushare-finance-pro
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /tushare-finance-pro 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
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估值、行业对比 - 支持定时推送及多种安装配置说明 - 价格方案与权益对比清晰明了
元数据
Slug tushare-finance-pro
版本 1.2.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 3
常见问题

Tushare 金融数据助手 是什么?

Tushare Pro 金融数据接口 - A股/港股/美股/基金/期货/债券/宏观经济,220+数据接口,支持财务报表、估值分析、行业研究. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 70 次。

如何安装 Tushare 金融数据助手?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install tushare-finance-pro」即可一键安装,无需额外配置。

Tushare 金融数据助手 是免费的吗?

是的,Tushare 金融数据助手 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Tushare 金融数据助手 支持哪些平台?

Tushare 金融数据助手 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Tushare 金融数据助手?

由 wangzhaofeng-max(@wangzhaofeng-max)开发并维护,当前版本 v1.2.0。

💬 留言讨论