專業財務分析助手

👤 wangzhaofeng-max 📦 v1.2.0 ⭐ 4.1 ⬇️ 643 下載
💼 行業專業 免費 🔑 需 API Key

📖 技能介紹


name: finance-analysis-pro description: 專業財務分析助手 - 財報分析、DCF估值、風險評估、行業對比、投資決策支援 metadata: openclaw: emoji: "💰" requires: pip: ["tushare>=1.2.89", "pandas>=1.5", "numpy>=1.24"] install: - id: pip-install kind: pip packages: ["tushare>=1.2.89", "pandas>=1.5", "numpy>=1.24"] label: "安裝依賴" keywords: - 財務分析 - 股票估值 - DCF模型 - 風險評估 - 投資決策 - 財報解讀


專業財務分析助手

功能特性

  • 基礎財報分析(自動重試機制)

    7w4.net收錄了海量優質技能外掛。

  • 財務指標計算
  • DCF 估值模型
  • 相對估值法
  • 風險評估報告
  • 行業對比分析
  • 自動投資建議
  • 定期分析推送
  • 智慧錯誤處理
  • 多資料來源支援

快速開始

pip install tushare pandas numpy
export TUSHARE_TOKEN="your_token"

財報分析

import tushare as ts
import pandas as pd

pro = ts.pro_api()

def analyze_stock(ts_code):
    """基礎財報分析"""
    # 獲取財務指標
    indicator = pro.fina_indicator(ts_code=ts_code, period='20231231')

    if indicator.empty:
        return "未找到資料"

    data = indicator.iloc[0]

    return {
        'ROE': data.get('roe', 'N/A'),
        '淨利率': data.get('netprofit_margin', 'N/A'),
        '毛利率': data.get('grossprofit_margin', 'N/A'),
        '資產負債率': data.get('debt_to_assets', 'N/A'),
        '營收增長': data.get('or_yoy', 'N/A'),
        '利潤增長': data.get('netprofit_yoy', 'N/A')
    }

# 使用示例
result = analyze_stock('000001.SZ')
print(result)

財務指標解讀

def interpret_indicators(indicators):
    """解讀財務指標"""
    interpretations = []

    # ROE 解讀
    roe = indicators.get('ROE', 0)
    if roe > 20:
        interpretations.append("ROE優秀 (>20%)")
    elif roe > 15:
        interpretations.append("ROE良好 (15-20%)")
    elif roe > 10:
        interpretations.append("ROE一般 (10-15%)")
    else:
        interpretations.append("ROE偏低 (<10%)")

    # 淨利率解讀
    net_margin = indicators.get('淨利率', 0)
    if net_margin > 30:
        interpretations.append("淨利率優秀 (>30%)")
    elif net_margin > 15:
        interpretations.append("淨利率良好 (15-30%)")
    elif net_margin > 5:
        interpretations.append("淨利率一般 (5-15%)")
    else:
        interpretations.append("淨利率偏低 (<5%)")

    # 增長率解讀
    growth = indicators.get('營收增長', 0)
    if growth > 30:
        interpretations.append("高增長 (>30%)")
    elif growth > 15:
        interpretations.append("穩健增長 (15-30%)")
    elif growth > 0:
        interpretations.append("低增長 (0-15%)")
    else:
        interpretations.append("負增長")

    return interpretations

DCF 估值模型

def dcf_valuation(ts_code, assumptions=None):
    """DCF 估值模型"""
    if assumptions is None:
        assumptions = {
            'growth_rate': 0.15,  # 未來5年增長率
            'terminal_growth': 0.03,  # 永續增長率
            'wacc': 0.10,  # 加權平均資本成本
            'margin_of_safety': 0.25  # 安全邊際
        }

    # 獲取歷史資料
    income = pro.income(ts_code=ts_code)
    if income.empty:
        return None

    latest = income.iloc[0]
    base_revenue = latest.get('revenue', 0)
    net_profit = latest.get('net_profit', 0)
    net_margin = net_profit / base_revenue if base_revenue > 0 else 0

    # 預測未來5年
    cash_flows = []
    for year in range(1, 6):
        revenue = base_revenue * (1 + assumptions['growth_rate']) ** year
        profit = revenue * net_margin
        cash_flows.append(profit)

    # 終值
    terminal_value = cash_flows[-1] * (1 + assumptions['terminal_growth']) / \
                    (assumptions['wacc'] - assumptions['terminal_growth'])

    # 折現
    pv_cash_flows = sum(cf / (1 + assumptions['wacc']) ** i 
                       for i, cf in enumerate(cash_flows, 1))
    pv_terminal = terminal_value / (1 + assumptions['wacc']) ** 5

    total_value = pv_cash_flows + pv_terminal

    # 應用安全邊際
    safe_value = total_value * (1 - assumptions['margin_of_safety'])

    return {
        '公司價值': total_value,
        '安全價值': safe_value,
        '現金流預測': cash_flows,
        '終值': terminal_value,
        '假設條件': assumptions
    }

相對估值法

def relative_valuation(ts_code, industry_pe=15, industry_pb=1.5):
    """相對估值法"""
    # 獲取基本面資料
    basic = pro.stock_basic(ts_code=ts_code, fields='ts_code,name,industry,market_cap')
    indicator = pro.fina_indicator(ts_code=ts_code, period='20231231')
    income = pro.income(ts_code=ts_code, period='20231231')

    if basic.empty or indicator.empty or income.empty:
        return None

    data = indicator.iloc[0]
    income_data = income.iloc[0]

    # 計算 EPS
    shares = data.get('total_share', 0)
    eps = income_data.get('net_profit', 0) / shares if shares > 0 else 0

    # 計算 BPS
    bvps = data.get('bvps', 0)

    # PE 估值
    pe_value = eps * industry_pe

    # PB 估值
    pb_value = bvps * industry_pb

    return {
        'EPS': eps,
        'BPS': bvps,
        'PE估值': pe_value,
        'PB估值': pb_value,
        '綜合估值': (pe_value + pb_value) / 2,
        '行業PE': industry_pe,
        '行業PB': industry_pb
    }

風險評估報告

def risk_assessment(ts_code):
    """風險評估"""
    indicator = pro.fina_indicator(ts_code=ts_code, period='20231231')
    balance = pro.balancesheet(ts_code=ts_code, period='20231231')

    if indicator.empty or balance.empty:
        return None

    ind = indicator.iloc[0]
    bal = balance.iloc[0]

    risks = []
    score = 100

    # 償債能力
    debt_ratio = ind.get('debt_to_assets', 0)
    if debt_ratio > 70:
        risks.append("⚠️ 資產負債率過高 (>70%)")
        score -= 20
    elif debt_ratio > 50:
        risks.append("⚡ 資產負債率偏高 (50-70%)")
        score -= 10

    # 盈利能力
    roe = ind.get('roe', 0)
    if roe < 5:
        risks.append("⚠️ ROE過低 (<5%)")
        score -= 15
    elif roe < 10:
        risks.append("⚡ ROE偏低 (5-10%)")
        score -= 5

    # 成長性
    growth = ind.get('or_yoy', 0)
    if growth < 0:
        risks.append("⚠️ 營收負增長")
        score -= 15
    elif growth < 10:
        risks.append("⚡ 增長放緩 (<10%)")
        score -= 5

    # 現金流
    ocf = ind.get('ocf_to_profit', 0)
    if ocf < 0.8:
        risks.append("⚠️ 現金流質量差")
        score -= 10

    # 評級
    if score >= 80:
        rating = "⭐⭐⭐⭐⭐ 低風險"
    elif score >= 60:
        rating = "⭐⭐⭐⭐ 中低風險"
    elif score >= 40:
        rating = "⭐⭐⭐ 中等風險"
    elif score >= 20:
        rating = "⭐⭐ 中高風險"
    else:
        rating = "⭐ 高風險"

    return {
        '風險評分': score,
        '風險評級': rating,
        '風險提示': risks,
        '關鍵指標': {
            '資產負債率': debt_ratio,
            'ROE': roe,
            '營收增長': growth,
            '現金流/利潤': ocf
        }
    }

行業對比分析

def industry_analysis(ts_code, top_n=10):
    """行業對比分析"""
    # 獲取公司資訊
    stock = pro.stock_basic(ts_code=ts_code, fields='ts_code,name,industry')
    if stock.empty:
        return None

    industry = stock.iloc[0]['industry']

    # 獲取同行業公司
    peers = pro.stock_basic(industry=industry, list_status='L',
                           fields='ts_code,name,market_cap')

    if peers.empty:
        return None

    peers = peers.sort_values('market_cap', ascending=False).head(top_n)

    results = []
    for _, peer in peers.iterrows():
        try:
            ind = pro.fina_indicator(ts_code=peer['ts_code'], period='20231231')
            if not ind.empty:
                results.append({
                    '程式碼': peer['ts_code'],
                    '名稱': peer['name'],
                    '市值(億)': peer['market_cap'] / 100000000,
                    'ROE': ind.iloc[0].get('roe', None),
                    '淨利率': ind.iloc[0].get('netprofit_margin', None),
                    '營收增長': ind.iloc[0].get('or_yoy', None)
                })
        except:
            continue

    df = pd.DataFrame(results)

    # 計算行業平均
    avg_metrics = {
        '行業平均ROE': df['ROE'].mean(),
        '行業平均淨利率': df['淨利率'].mean(),
        '行業平均增長': df['營收增長'].mean()
    }

    return {
        '行業': industry,
        '對比公司': df,
        '行業平均': avg_metrics
    }

使用示例

# 財報分析
python scripts/finance_analysis.py analyze --stock 000001.SZ

# DCF 估值
python scripts/finance_analysis.py valuation --stock 600519.SH --method dcf

# 風險評估
python scripts/finance_analysis.py risk --stock 000001.SZ

# 行業對比
python scripts/finance_analysis.py industry --stock 600519.SH

風險提示

  1. 估值模型基於假設,實際結果可能差異較大
  2. 財務資料存在滯後性
  3. 投資有風險,決策需謹慎

🤖 AI 評測

這是一款功能較為豐富的財務分析工具,文件詳細、操作友好,能滿足基礎的財報解讀和估值需求。但核心的估值計算功能使用的是示例資料而非真實計算結果,資料準確性有待提升。此外,工具依賴tushare資料介面,需要配置API Token才能獲取真實資料。總體而言,框架搭建完整,但實際使用效果受限於資料來源的配置和計算邏輯的完善程度。

📊 多維度評分

適應性4.2
規範性4.1
有效性3.8
可靠性3.9
可信度5

📁 包含檔案 (7 個)

📄 README.md 3.6 KB
📄 SKILL.md 9.3 KB
📄 _meta.json 139 B
📄 package.json 942 B
📄 scripts/finance_analysis.py 8.2 KB
📄 scripts/valuation.py 10.5 KB
📄 skill-card.md 2.1 KB