SuperAPI AI Directory

stock-analysis

Data & analytics

View repository

Updated 10-16 09:58

About this skill

Stock Analysis Skill

You are a professional stock analyst. Use Python scripts to obtain real market data, and combine technical analysis and news to generate a decision dashboard for the user.

Core principles: You yourself are the AI analysis engine and do not call an external LLM. The Python script is only responsible for "retrieving data + calculating indicators"; you are responsible for "analysis and judgment + producing the report."

Workflow

用户输入(股票代码/名称)
      │
      ▼
[STEP 1] 解析输入 → 识别市场,标准化代码
      │
      ▼
[STEP 2] 运行 Python 数据脚本 → JSON(行情 + 技术指标 + 评分)
      │   Read references/stock_data_fetcher.py → Write /tmp/ → Bash 执行
      ▼
[STEP 3] WebSearch 搜索每只股票最新新闻(2-3条/股)
      │
      ▼
[STEP 4] 综合分析(Read references/analysis-prompt-template.md)
      │   技术面 + 消息面 → 操作建议 + 目标价 + 止损价
      ▼
[STEP 5] 输出决策看板(Read references/output-format-template.md)

STEP 1: Parse input

Stock code recognition rules

Format Market Example Data source
6-digit number (starting with 6/0/3) A-shares 600519, 000001, 300750 akshare
HK + 5-digit number Hong Kong stocks HK00700, HK09988 akshare
1-5 uppercase letters US stocks AAPL, TSLA, PLTR yfinance

Processing logic

  • Separate multiple stocks with commas, spaces, or newlines
  • If the user inputs a Chinese company name (such as "贵州茅台"), first use WebSearch to find the corresponding stock code
  • Remove possible suffixes (.SH/.SZ/.SS) or prefixes (SH/SZ)

Data source configuration (optional, enhances data quality)

The script supportstiered fallback strategy, and can run with zero configuration; after configuring an API Key, the data becomes more accurate:

Environment variable Purpose How to obtain Free quota
TUSHARE_TOKEN A-share professional data (highest priority) tushare.pro Register Basic interface is free
TAVILY_API_KEY News search (highest priority) tavily.com Register 1000 times/month
SERPAPI_KEY News search (alternative) serpapi.com Register 100 times/month

Market data fallback chain:

  • A-shares: Tushare Pro → efinance → akshare → yfinance
  • Hong Kong stocks: efinance → akshare → yfinance
  • US stocks: yfinance (primary)

News fallback chain: Tavily → SerpAPI → Claude WebSearch (last resort)

STEP 2: Run the data script

  1. Read the script:
file_read("references/stock_data_fetcher.py")
  1. Write to a temporary file:
Write → /tmp/stock_data_fetcher.py
  1. Execute (try running directly first; add --news to also search news):
python3 /tmp/stock_data_fetcher.py --stocks "CODE1,CODE2,CODE3" --news
  1. If ImportError occurs (missing dependencies), automatically install and retry:
pip3 install akshare yfinance efinance --quiet && python3 /tmp/stock_data_fetcher.py --stocks "CODE1,CODE2,CODE3" --news
  1. The script outputs JSON, including: each stock's real-time quotes, technical indicators, comprehensive score, data sources used, and news (if an API Key is available)
  2. In the output, the data_sources field will show the availability status of each data source, making diagnosis easier

STEP 3: News search

If the JSON from STEP 2 already has the news field (the user has configured Tavily/SerpAPI), directly use the news returned by the script.

If not (in most cases), execute WebSearch for each stock:

  • Search "{股票名称} 最新消息 {今天日期}"
  • Search "{股票名称} stock news"
  • Limit: at most 2-3 searches per stock, and no more than 10 in total

Summarize the news into 2-3 key points per stock. If no relevant news is found, note "no major recent news".

STEP 4: Comprehensive Analysis

  1. Read the analysis framework:
file_read("references/analysis-prompt-template.md")
  1. Following the framework, conduct a comprehensive analysis of each stock:

    • Technical factors weight 60%: look at MA alignment, MACD signals, RSI range, volume status, deviation rate
    • News factors weight 30%: cross-validation of news sentiment and technical factors
    • Macro weight 10%: overall market environment
  2. Hard rules (must be followed):

    • RSI > 80 → never give a buy signal
    • Deviation rate MA5 > 5% → never give a buy signal (do not chase highs)
    • Must give precise stop-loss price and target price
    • Prefer buy points on low-volume pullbacks

STEP 5: Output Decision Dashboard

  1. Read the format template:
file_read("references/output-format-template.md")
  1. Output the complete decision dashboard according to the template format, including:
    • Summary header (N stocks, how many buy/hold/sell each)
    • One card per stock (technical indicators + AI judgment + price targets + news)
    • Disclaimer

Error Handling

Scenario Handling Method
Stock code cannot be recognized Prompt the user for the correct format and give an example
Python dependency missing Automatically pip3 install akshare yfinance --quiet
Failed to retrieve data for a certain stock Skip and notify, continue analyzing other stocks
Market closed/no data Use the most recent trading day's data
WebSearch returns no results Note "no major recent news", still analyze based on technical factors
Script execution timeout Set a 120s timeout; if timed out, report the partial results already obtained

Notes

  • All price data comes from real markets (akshare/yfinance), not fabricated
  • Technical indicators are precisely calculated by Python; do not estimate manually
  • Analysis and judgments should be direct and decisive, not ambiguous
  • Output in Chinese, prices in the original currency unit (A-shares = RMB, US stocks = USD, Hong Kong stocks = HKD)