Skill: laigen/a-share-global-peer (version 1.0.2)

--- name: a-share-global-peer description: "Find global peer companies for A-share listed companies. Input an A-share company name or code, automatically match overseas listed companies (US, Europe, Japan, Korea) offering similar products/services, output comparison report with market share data. Triggers when user asks for overseas peer/benchmark, comparing A-share vs global leaders, or keywords like 对标, peer comparison, benchmark." metadata: openclaw: requires: env: - name: TUSHARE_TOKEN required: false description: "Tushare API token for A-share company data (optional, fallback to Web Search)" - name: BRAVE_API_KEY required: false description: "Brave Search API key (optional, system default available)" tools: - web_search - exec skills: - ifind-finance-data - tushare-data - akshare-stock --- # A-Share Global Peer Matching Tool ## Overview This skill helps find overseas listed companies that can serve as benchmarks or peers for A-share (Chinese) listed companies. It matches companies based on product/service similarity and provides detailed comparison reports. ## Dependencies ### Required Tools | Tool | Purpose | Priority | |------|---------|----------| | `web_search` | Search for global leaders, market share data | **Required** | | `exec` | Run Python scripts for data fetching | Required | | `read` | Read reference files | Optional | ### Optional Skills (Enhancement) | Skill | Purpose | Benefit | |-------|---------|---------| | `ifind-finance-data` | Query A-share company products/financials | Highest accuracy | | `tushare-data` | A-share company basic info | Structured data | | `akshare-stock` | A-share market data | Alternative data source | ### Environment Variables | Variable | Required | Description | |----------|----------|-------------| | `TUSHARE_TOKEN` | Optional | Tushare API token. If not set, falls back to Web Search for company data | | `BRAVE_API_KEY` | Optional | Brave Search API key. System default available | **Note**: This skill works without any API keys by using Web Search fallback. API keys enhance data quality but are not mandatory. ### Required Files (Bundled) | File | Purpose | |------|---------| | `scripts/get_company_products.py` | Fetch A-share company product info | | `references/global_leaders_reference.md` | Quick lookup table for global leaders | --- ## Workflow ### Step 1: Get A-Share Company Product Matrix **Data Source Priority**: iFinD (if skill available) > Tushare (if token set) > Web Search (always available) Execute: ```bash python3 scripts/get_company_products.py --company "<company_name_or_code>" --output json ``` The script automatically: 1. Checks for `TUSHARE_TOKEN` environment variable 2. If available, queries Tushare API 3. If unavailable, returns recommended Web Search queries Expected output: - Main products/services (sorted by revenue %) - Industry classification - Revenue geography breakdown **Fallback**: If script unavailable or no API token, use web_search with query: - `"<公司名> 主营业务 营收构成 2024"` - `"<公司名> products revenue breakdown"` --- ### Step 2: Search for Global Peer Companies **Search Strategy**: 1. For each major product, search `"global leader in [product_name]"` or `"[product_name] market share"` 2. Prioritize US-listed companies (data easier to obtain), then Europe, Japan, Korea 3. Use `web_search` tool, label source as "Web Search" **Selection Criteria**: - MUST be publicly listed (exclude private companies) - Prefer highest market share in same product category - Higher product matrix overlap = higher priority --- ### Step 3: Handle Special Cases #### Region-Specific Products When A-share company products have strong regional/Chinese characteristics: - Find overseas products with similar regional characteristics for analogy - Examples: - Baijiu (白酒) → Whisky leader (Diageo) - Chinese condiments → Western condiments (McCormick) - Mark as "类比对标 (Analogy Benchmark)" and explain logic #### Diversified Business When A-share company operates multiple product categories: - First try to find single overseas company with highest product matrix overlap - If impossible, benchmark by main product separately - Example: Xiaomi (phone + IoT) → Apple (phone + IoT ecosystem), not separate benchmarks --- ### Step 4: Get Market Share Data Search patterns: ``` "[company_name] [product] market share" "[product] global market share ranking" "[product] industry leaders 2024" ``` Label all data sources: - `数据来源: Web Search (YYYY-MM-DD)` - `数据来源: iFinD API` - `数据来源: Tushare API` --- ### Step 5: Output Comparison Report (Chinese) **Important**: All output reports must be in **Chinese** for user readability. Output template: ```markdown ## A股公司 vs 海外对标 ### A股公司：[公司名] ([股票代码]) - **主营产品**: [产品1] (营收占比 XX%), [产品2] (营收占比 XX%) - **行业**: [行业分类] - **地域特色**: [如有则说明] ### 海外对标 1：[公司名] ([股票代码] - [交易所]) - **主营产品**: [产品1] (营收占比 XX%), [产品2] (营收占比 XX%) - **市场地位**: [描述] - **市场份额数据**: - [产品1] 全球份额: XX% (数据来源: ...) - [产品2] 全球份额: XX% (数据来源: ...) ### 海外对标 2：[公司名] ([股票代码] - [交易所]) - **主营产品**: ... - **市场地位**: ... ### 产品对比 | 产品维度 | A股公司 | 海外对标1 | 海外对标2 | |---------|---------|----------|----------| | [维度名] | [数值] | [数值] | [数值] | | 毛利率 | XX% | XX% | XX% | | 营收规模 | XX亿 | XX亿 | XX亿 | ### 对标逻辑说明 - [选择这家公司对标的原因] - [地域特色类比依据，如有] --- *数据获取时间: YYYY-MM-DD* ``` --- ## Examples ### Example 1: CATL (宁德时代) Input: "宁德时代的海外对标公司" Workflow: 1. Query CATL main products: EV batteries (~70% revenue) 2. Search "global leader in EV battery" 3. Results: LG Energy Solution, Panasonic, Samsung SDI 4. Get market share data 5. Output Chinese comparison report ### Example 2: Kweichow Moutai (贵州茅台) Input: "茅台对标哪家海外公司" Workflow: 1. Identify Moutai products: Baijiu (strong regional characteristic) 2. Search "global leader in spirits" 3. Result: Diageo (whisky leader) 4. Mark as "类比对标: 白酒 vs 威士忌" 5. Output analogy comparison report in Chinese ### Example 3: Innolight (中际旭创) Input: "中际旭创的海外对标" Workflow: 1. Query: Optical transceivers (95.9% revenue) 2. Search "global optical transceiver market leader" 3. Results: Coherent, Lumentum 4. **Special finding**: Innolight is already #1 globally! 5. Output competition benchmark report, note leadership position --- ## Resource Files ### scripts/ - `get_company_products.py` - Fetch A-share company product info via Tushare or recommend Web Search fallback ### references/ - `global_leaders_reference.md` - Quick lookup table for global industry leaders Read reference file to reduce redundant searches: ```markdown # Quick lookup example - EV Battery → LG Energy Solution (373220.KRX), Panasonic (6752.TSE) - Spirits → Diageo (DEO.NYSE), Brown-Forman (BF.A.NYSE) - Optical Transceiver → Coherent (COHR.NYSE), Lumentum (LITE.NYSE) ``` --- ## Data Source Labeling Rules | Data Type | Label Format | |-----------|--------------| | A-share company products | `数据来源: iFinD API` or `数据来源: Tushare API` or `数据来源: Web Search` | | Overseas company info | `数据来源: Web Search (YYYY-MM-DD)` | | Market share | `数据来源: Web Search (YYYY-MM-DD)` + search keywords | | Estimates/speculation | Explicitly label `推测数据，需验证` | --- ## Important Rules 1. **NEVER fabricate data** - All market share figures must come from actual search results 2. **Label uncertainty** - Clearly state when data is incomplete 3. **Max 2 peer companies** - Avoid information overload, select most representative 4. **Prioritize listed companies** - Exclude private companies (e.g., Bosch, Deloitte) 5. **Output in Chinese** - User-facing reports must be in Chinese for readability 6. **Check leadership position** - Some A-share companies may already be global leaders (e.g., Innolight, CATL) 7. **Graceful fallback** - If API tokens unavailable, use Web Search instead of failing --- ## Special Cases Handling ### Case 1: A-Share Company is Global Leader When A-share company already ranks #1 globally: - Change framing from "对标学习" to "竞争对标" (competition benchmark) - Note that overseas companies are competitors, not learning targets - Focus on competitive dynamics, technology divergence, customer overlap Example: 中际旭创 (Innolight) surpassed Coherent to become #1 optical transceiver supplier in 2024. ### Case 2: No Direct Global Peer When no listed overseas company produces exact same product: - Use analogy benchmarking - Explain analogy logic clearly - Note limitations of analogy comparison Example: 中国中药 → Western herbal supplements (GNC, privatized, limited options) ### Case 3: Multiple Product Categories When company has diversified business: - Try to find single comprehensive peer first - If impossible, benchmark main product only - Note "多元化经营，仅对标主营业务" --- ## Quality Checklist Before outputting report, verify: - [ ] All revenue percentages backed by data sources - [ ] Market share figures labeled with source - [ ] Overseas companies confirmed as publicly listed - [ ] Special cases (regional products, diversified) handled properly - [ ] Report language is Chinese - [ ] Data timestamp included - [ ] If A-share company is global leader, noted in report

path: references/global_leaders_reference.md
content: # Global Industry Leaders Reference Table

Quick lookup table for common industry global leaders. **Note**: Market share data changes, verify before use.

---

## Consumer Electronics & Technology

| Industry/Product | Global Leader | Stock Code | Exchange |
|------------------|---------------|------------|----------|
| Consumer Electronics/Smartphone | Apple | AAPL | NASDAQ |
| Semiconductor Equipment | NVIDIA, ASML | NVDA, ASML | NASDAQ |
| Semiconductor Manufacturing | Taiwan Semiconductor | TSM | NYSE |
| Semiconductor Design | Broadcom, AMD | AVGO, AMD | NASDAQ |
| Enterprise Software | Microsoft | MSFT | NASDAQ |
| Cloud Services | Amazon AWS | AMZN | NASDAQ |
| Social Media | Meta | META | NASDAQ |
| Search Engine | Google | GOOGL | NASDAQ |
| E-commerce Platform | Amazon | AMZN | NASDAQ |

---

## Automotive & New Energy

| Industry/Product | Global Leader | Stock Code | Exchange |
|------------------|---------------|------------|----------|
| Electric Vehicles | Tesla | TSLA | NASDAQ |
| EV Battery | LG Energy Solution | 373220 | KRX (Korea) |
| EV Battery | Panasonic | 6752 | TSE (Japan) |
| EV Battery | Samsung SDI | 006400 | KRX (Korea) |
| Traditional Auto | Toyota | TM | NYSE |
| Traditional Auto | Volkswagen | VOW3 | XETRA (Germany) |

---

## Optical & Communication

| Industry/Product | Global Leader | Stock Code | Exchange |
|------------------|---------------|------------|----------|
| Optical Transceiver | Coherent | COHR | NYSE |
| Optical Transceiver | Lumentum | LITE | NYSE |
| Optical Components | Broadcom | AVGO | NASDAQ |
| Telecom Equipment | Nokia | NOK | NYSE |
| Telecom Equipment | Ericsson | ERIC | NASDAQ |

---

## Food & Beverage

| Industry/Product | Global Leader | Stock Code | Exchange |
|------------------|---------------|------------|----------|
| Spirits (Whisky etc.) | Diageo | DEO | NYSE (ADR) |
| Spirits (American Whiskey) | Brown-Forman | BF.A/BF.B | NYSE |
| Beer | Anheuser-Busch InBev | BUD | NYSE |
| Soft Drinks | Coca-Cola | KO | NYSE |
| Snacks/Food | PepsiCo | PEP | NASDAQ |
| Cosmetics/Beauty | L'Oréal | LRLCY | OTC (ADR) |
| Household Products | Procter & Gamble | PG | NYSE |
| Household Products | Unilever | UL | NYSE |

---

## Healthcare & Medical Devices

| Industry/Product | Global Leader | Stock Code | Exchange |
|------------------|---------------|------------|----------|
| Pharmaceuticals (Innovative) | Pfizer | PFE | NYSE |
| Pharmaceuticals (Innovative) | Merck | MRK | NYSE |
| Pharmaceuticals (Innovative) | Johnson & Johnson | JNJ | NYSE |
| Medical Devices | Medtronic | MDT | NYSE |
| Medical Devices | Abbott | ABT | NYSE |
| Diagnostics | Thermo Fisher | TMO | NYSE |

---

## Financial Services

| Industry/Product | Global Leader | Stock Code | Exchange |
|------------------|---------------|------------|----------|
| Banking (Global) | JPMorgan Chase | JPM | NYSE |
| Banking (Global) | HSBC | HSBC | NYSE |
| Life Insurance | MetLife | MET | NYSE |
| Property Insurance | Allianz | ALIZY | OTC (ADR) |
| Investment Banking | Goldman Sachs | GS | NYSE |

---

## Industrial & Materials

| Industry/Product | Global Leader | Stock Code | Exchange |
|------------------|---------------|------------|----------|
| Construction Equipment | Caterpillar | CAT | NYSE |
| Construction Equipment | Komatsu | 6301 | TSE (Japan) |
| Chemical Materials | BASF | BASFY | OTC (ADR) |
| Chemical Materials | Dow | DOW | NYSE |
| Steel | Nucor | NUE | NYSE |
| Aerospace | Boeing | BA | NYSE |

---

## Retail

| Industry/Product | Global Leader | Stock Code | Exchange |
|------------------|---------------|------------|----------|
| E-commerce Platform | Amazon | AMZN | NASDAQ |
| E-commerce Platform | Alibaba | BABA | NYSE |
| Cross-border E-commerce | Shopify | SHOP | NYSE |
| Supermarket Retail | Walmart | WMT | NYSE |
| Warehouse Retail | Costco | COST | NASDAQ |

---

## Emerging Technologies

| Industry/Product | Global Leader | Stock Code | Exchange |
|------------------|---------------|------------|----------|
| AI Infrastructure | NVIDIA | NVDA | NASDAQ |
| AI Software | Microsoft, Google | MSFT, GOOGL | NASDAQ |
| Robotics | Fanuc | 6954 | TSE (Japan) |
| Energy Storage | Fluence | FLNC | NASDAQ |

---

## Chinese Regional Product Analogies

When A-share products have strong Chinese/regional characteristics, use these analogies:

| A-Share Product | Analogous Global Product | Peer Company | Analogy Logic |
|------------------|--------------------------|--------------|---------------|
| Baijiu (白酒) | Whisky/Spirits | Diageo (DEO) | Premium alcohol, cultural heritage |
| Baijiu (白酒) | Bourbon | Brown-Forman (BF.A) | Strong regional identity (Tennessee vs贵州) |
| Chinese Condiments | Western Condiments | McCormick (MKC) | Seasoning/convenience food |
| Chinese Fast Food | Western Fast Food | McDonald's (MCD) | Chain restaurant model |
| Chinese Medicine | Herbal Supplements | GNC (私有化, privatized) | Traditional medicine (limited options) |
| Tea Drinks | Coffee Drinks | Starbucks (SBUX) | Beverage retail chain |

**Note**: Mark these as "类比对标 (Analogy Benchmark)" in reports.

---

## Usage Guidelines

1. **Quick Lookup**: Find corresponding global leader by A-share company's industry
2. **Verify Data**: This table provides clues only, market share must be verified via Web Search
3. **Diversified Business**: If A-share company spans multiple industries, lookup multiple categories
4. **Regional Products**: Use analogy mapping table for region-specific products

---

## Important Notes

- Market share and leadership positions change frequently
- Some leaders may be private companies (excluded from this table)
- Japanese companies trade on TSE (Tokyo Stock Exchange)
- Korean companies trade on KRX (Korea Exchange)
- German companies trade on XETRA
- ADR = American Depositary Receipt (US trading of foreign stock)

---

*Table updated: 2026-04-14*

path: scripts/get_company_products.py
content: #!/usr/bin/env python3
"""
Get A-share listed company main product information

Data source priority: iFinD (via skill) > Tushare (env var) > Web Search fallback

Usage:
    python3 get_company_products.py --company "宁德时代" --output json
    python3 get_company_products.py --company "300750" --output text
    python3 get_company_products.py --company "贵州茅台" --recommend-search

Environment Variables:
    TUSHARE_TOKEN: Tushare API token (optional, enables Tushare API queries)

Output includes:
- Main products/services (sorted by revenue %)
- Industry classification
- Revenue geography breakdown
- Recommended Web Search queries if API unavailable
"""

import argparse
import json
import sys
import os
from datetime import datetime

# Try to load Tushare
try:
    import tushare as ts
    TUSHARE_AVAILABLE = True
except ImportError:
    TUSHARE_AVAILABLE = False


def get_tushare_token() -> str | None:
    """
    Get Tushare token from environment variable.
    
    Returns None if not set (graceful fallback to Web Search).
    """
    return os.environ.get('TUSHARE_TOKEN')


def get_from_tushare(company: str, token: str) -> dict | None:
    """Query company info via Tushare API"""
    if not TUSHARE_AVAILABLE:
        print("Tushare package not installed", file=sys.stderr)
        return None
    
    try:
        ts.set_token(token)
        pro = ts.pro_api()
        
        # Search stock by code or name
        if company.isdigit() and len(company) == 6:
            # Likely a stock code - try different exchanges
            exchanges = ['SH', 'SZ', 'BJ']
            for exchange in exchanges:
                df = pro.stock_basic(ts_code=f"{company}.{exchange}", fields='ts_code,name,industry,market')
                if not df.empty:
                    break
        else:
            # Company name search
            df = pro.stock_basic(name=company, fields='ts_code,name,industry,market')
        
        if df.empty:
            return None
        
        row = df.iloc[0]
        ts_code = row['ts_code']
        company_name = row['name']
        industry = row.get('industry', 'N/A')
        market = row.get('market', 'N/A')
        
        return {
            'company': company_name,
            'ts_code': ts_code,
            'industry': industry,
            'market': market,
            'source': 'Tushare API',
            'products': [],
            'note': 'Tushare provides basic info only. Use Web Search or iFinD skill for detailed product breakdown.'
        }
        
    except Exception as e:
        print(f"Tushare query failed: {e}", file=sys.stderr)
        return None


def get_from_ifind(company: str) -> dict:
    """
    Query company info via iFinD MCP tool
    
    Note: This requires the ifind-finance-data skill to be available.
    The actual query should be done through the skill's MCP tools, not here.
    """
    return {
        'company': company,
        'source': 'iFinD (requires MCP tool)',
        'note': 'iFinD query should be done via ifind-finance-data skill MCP tools',
        'recommendation': 'Use ifind-finance-data skill for most accurate company product data'
    }


def generate_web_search_queries(company: str, industry: str = '') -> list[str]:
    """Generate recommended Web Search queries for product details"""
    queries = [
        f"{company} 主营业务 营收构成 2024",
        f"{company} 产品结构 收入占比",
        f"{company} revenue breakdown products 2024",
    ]
    
    if industry and industry != 'N/A':
        queries.append(f"{company} {industry} 产品 业务")
    
    return queries


def main():
    parser = argparse.ArgumentParser(
        description='Get A-share company main product information',
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog='''
Examples:
    python3 get_company_products.py --company "宁德时代" --output json
    python3 get_company_products.py --company "300750" --output text
    python3 get_company_products.py --company "贵州茅台" --recommend-search

Environment:
    TUSHARE_TOKEN: Optional Tushare API token (enables structured data queries)
        '''
    )
    parser.add_argument('--company', required=True, help='A-share company name or 6-digit stock code')
    parser.add_argument('--output', default='json', choices=['json', 'text'], help='Output format')
    parser.add_argument('--recommend-search', action='store_true', help='Output recommended search queries')
    args = parser.parse_args()
    
    result = {
        'query': args.company,
        'timestamp': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
        'status': 'success',
        'data_source': None,
        'company_info': None,
        'recommended_searches': [],
        'env_status': {
            'TUSHARE_TOKEN': 'not_set',
            'tushare_package': TUSHARE_AVAILABLE
        }
    }
    
    # Check environment
    tushare_token = get_tushare_token()
    if tushare_token:
        result['env_status']['TUSHARE_TOKEN'] = 'set'
    
    # Try Tushare first if token available
    if tushare_token and TUSHARE_AVAILABLE:
        tushare_data = get_from_tushare(args.company, tushare_token)
        if tushare_data:
            result['data_source'] = 'Tushare API'
            result['company_info'] = tushare_data
            result['recommended_searches'] = generate_web_search_queries(
                tushare_data.get('company', args.company),
                tushare_data.get('industry', '')
            )
        else:
            result['status'] = 'partial'
            result['data_source'] = 'Web Search Fallback'
            result['recommendation'] = f'Tushare query failed. Use Web Search fallback.'
            result['recommended_searches'] = generate_web_search_queries(args.company)
    else:
        # No token or package - use Web Search fallback
        result['status'] = 'success'
        result['data_source'] = 'Web Search Fallback'
        reason = []
        if not tushare_token:
            reason.append('TUSHARE_TOKEN not set')
        if not TUSHARE_AVAILABLE:
            reason.append('tushare package not installed')
        result['recommendation'] = f'Using Web Search fallback: {", ".join(reason)}'
        result['recommended_searches'] = generate_web_search_queries(args.company)
    
    # Output
    if args.output == 'json':
        print(json.dumps(result, ensure_ascii=False, indent=2))
    else:
        print(f"=== A-Share Company Product Query ===")
        print(f"Query: {args.company}")
        print(f"Timestamp: {result['timestamp']}")
        print(f"Status: {result['status']}")
        print(f"Data Source: {result['data_source']}")
        
        print(f"\n--- Environment Status ---")
        print(f"TUSHARE_TOKEN: {result['env_status']['TUSHARE_TOKEN']}")
        print(f"Tushare Package: {result['env_status']['tushare_package']}")
        
        if result['company_info']:
            info = result['company_info']
            print(f"\n--- Company Info ---")
            print(f"Name: {info.get('company', 'N/A')}")
            print(f"Stock Code: {info.get('ts_code', 'N/A')}")
            print(f"Industry: {info.get('industry', 'N/A')}")
            print(f"Market: {info.get('market', 'N/A')}")
            print(f"Source: {info.get('source', 'N/A')}")
        
        if args.recommend_search and result['recommended_searches']:
            print(f"\n--- Recommended Web Searches ---")
            for i, query in enumerate(result['recommended_searches'], 1):
                print(f"{i}. {query}")
        
        if result.get('recommendation'):
            print(f"\nRecommendation: {result['recommendation']}")


if __name__ == '__main__':
    main()

Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)