Skill: wenhulove333/stock-sector-hunter (version 1.0.0)

--- name: stock-sector-hunter description: > 沪深强势板块个股探测器。通过联网搜索实时获取A股当日活跃板块、涨停龙头股， 支持按代码前缀过滤（00开头深证、60开头沪市），输出结构化板块+龙头个股列表。 触发词：强势板块、涨停龙头、今日热门、热点板块、个股探测 --- # 沪深强势板块个股探测器 ## 功能说明 通过联网搜索获取A股当日（截至当前交易日）沪深两市活跃板块及对应龙头个股， 支持按股票代码前缀过滤： | 前缀 | 市场 | |------|------| | 00 | 深圳主板/创业板 | | 60 | 上海主板 | | 00+60 | 沪深全部（默认） | ## 使用方式 ### 方式一：直接发送指令 发送以下指令之一即可触发： - "找今日强势板块" / "今日热点板块" - "涨停龙头有哪些" / "今日涨停股" - "帮我探测强势板块个股" - "沪深强势板块" ### 方式二：带过滤条件 - "00开头的涨停龙头" → 只返回 00 开头个股 - "60开头的热门板块" → 只返回 60 开头个股 - "今日强势板块只要60开头" → 同上 ### 方式三：指定板块 - "机器人概念龙头有哪些" → 返回机器人板块个股 - "半导体板块今日强势股" → 返回半导体板块个股 ## 输出格式 ``` 📊 【今日强势板块】2026年5月15日 ━━ 🤖 机器人概念 ━━━ 🏆 巨轮智能 | 002031 | 涨停 | 80万手封单，RV减速器打破国外垄断 雷赛智能 | — | 涨停 | 电机龙头 科力尔 | — | 涨停 | 微特电机 中马传动 | — | 涨停 | 传动装置 ... ━━ 🧪 氟化工概念 ━━━ 🏆 滨化股份 | 601678 | 一字涨停 | 氟化工龙头 中欣氟材 | 002915 | 一字涨停 | 氟化工 多氟多 | — | 涨停 | 氟化盐 ... ⚠️ 免责声明：以上内容仅供参考，不构成投资建议。 ``` ## 技术实现 - **搜索工具**：byted-web-search（火山引擎联网搜索） - **搜索词模板**： - 默认：`[日期] A股 强势板块 涨停龙头` - 过滤00：`[日期] A股 00开头 涨停龙头 强势板块` - 过滤60：`[日期] A股 60开头 涨停龙头 强势板块` - 指定板块：`[日期] [板块名] 概念 涨停龙头 强势股` - **过滤逻辑**：从搜索结果中提取提及 00/60 开头代码的股票，优先提取涨停、一字涨停等关键词 - **排序规则**：涨停 > 一字涨停 > 大涨 > 跟涨 ## 依赖 - byted-web-search skill（需已配置 `WEB_SEARCH_API_KEY`） - Python3 ## 文件结构 ``` stock-sector-hunter/ ├── SKILL.md └── scripts/ └── sector_hunter.py # 搜索+解析+格式化脚本 ```

path: scripts/ma_filter.py
content: #!/usr/bin/env python3
"""
均线选股器：获取5日均线和10日均线同时向上的股票（MA5 > MA10 且向上）
"""

import akshare as ak
import pandas as pd
from datetime import datetime, timedelta


def get_a_stock_codes(prefix_filter="all", limit=None):
    """获取A股代码列表"""
    df = ak.stock_info_a_code_name()
    
    # 过滤 00 和 60 开头
    mask = df['code'].str.startswith('00') | df['code'].str.startswith('60')
    df = df[mask]
    
    codes = df['code'].tolist()
    if limit:
        codes = codes[:limit]
    
    return codes


def check_ma_status(symbol):
    """检查单只股票的均线状态"""
    try:
        # symbol 格式: sz000001 或 sh600001
        df = ak.stock_zh_a_daily(symbol=symbol, adjust='qfq')
        
        if df is None or len(df) < 15:
            return None
        
        # 计算均线
        df['ma5'] = df['close'].rolling(window=5).mean()
        df['ma10'] = df['close'].rolling(window=10).mean()
        
        # 取最近2天
        latest = df.iloc[-1]
        prev = df.iloc[-2]
        
        # 条件判断
        ma5_above_ma10 = latest['ma5'] > latest['ma10']     # MA5 > MA10
        ma5_up = latest['ma5'] > prev['ma5']               # MA5 比昨天高（向上）
        ma10_up = latest['ma10'] > prev['ma10']            # MA10 比昨天高（向上）
        
        if ma5_above_ma10 and ma5_up and ma10_up:
            return {
                'close': round(latest['close'], 2),
                'ma5': round(latest['ma5'], 2),
                'ma10': round(latest['ma10'], 2),
                'date': str(latest.name)
            }
        
        return None
        
    except Exception as e:
        return None


def main():
    print("=" * 60)
    print("📊 均线多头选股器 | 5日线 > 10日线 且 均向上")
    print("=" * 60)
    
    # 获取股票列表
    codes = get_a_stock_codes(limit=500)  # 先测500只
    print(f"\n📋 00/60 开头股票共 {len(codes)} 只，开始扫描...\n")
    
    results = []
    
    for i, code in enumerate(codes):
        # 构建 symbol
        symbol = f"sz{code}" if code.startswith('00') else f"sh{code}"
        
        if (i + 1) % 100 == 0:
            print(f"  🔄 已扫描 {i+1}/{len(codes)} ...")
        
        result = check_ma_status(symbol)
        if result:
            results.append({
                'code': code,
                **result
            })
            print(f"  ✅ {code}: 現價={result['close']}, MA5={result['ma5']}, MA10={result['ma10']}")
    
    print(f"\n{'='*60}")
    print(f"📊 扫描结果：共找到 {len(results)} 只股票")
    print(f"   条件：MA5 > MA10（金叉多头）且 MA5向上 且 MA10向上")
    print(f"{'='*60}\n")
    
    if results:
        # 按代码排序
        results.sort(key=lambda x: x['code'])
        
        print(f"{'代码':<8} {'現價':>8} {'MA5':>8} {'MA10':>8}")
        print("-" * 40)
        for r in results:
            print(f"{r['code']:<8} {r['close']:>8.2f} {r['ma5']:>8.2f} {r['ma10']:>8.2f}")
    
    print(f"\n⚠️ 免责声明：以上内容仅供参考，不构成投资建议。")


if __name__ == "__main__":
    main()

path: scripts/ma_filter_em.py
content: #!/usr/bin/env python3
"""
均线多头选股器 - 东方财富API直连版
更快的方式获取数据
"""

import requests
import pandas as pd
from concurrent.futures import ThreadPoolExecutor, as_completed
import time


def get_ma_data_eastmoney(code, market):
    """使用东方财富API获取单只股票数据"""
    try:
        # 东财API获取股票日线数据
        url = f"http://push2his.eastmoney.com/api/qt/stock/kline/get"
        params = {
            "secid": f"{market}.{code}",
            "fields1": "f1,f2,f3,f4,f5,f6",
            "fields2": "f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",
            "klt": "101",  # 日线
            "fqt": "1",    # 前复权
            "beg": "20250501",
            "end": "20260630",
            "lmt": "20"    # 只取最近20天
        }
        
        resp = requests.get(url, params=params, timeout=5)
        data = resp.json()
        
        if data.get('data') and data['data'].get('klines'):
            klines = data['data']['klines']
            if len(klines) < 15:
                return None
            
            # 解析数据
            dates = []
            closes = []
            for kline in klines:
                parts = kline.split(',')
                dates.append(parts[0])
                closes.append(float(parts[2]))
            
            # 计算MA
            closes_series = pd.Series(closes)
            ma5 = closes_series.rolling(5).mean().iloc[-1]
            ma10 = closes_series.rolling(10).mean().iloc[-1]
            ma5_prev = closes_series.rolling(5).mean().iloc[-2]
            ma10_prev = closes_series.rolling(10).mean().iloc[-2]
            
            if ma5 > ma10 and ma5 > ma5_prev and ma10 > ma10_prev:
                return {
                    'code': code,
                    'close': closes[-1],
                    'ma5': round(ma5, 2),
                    'ma10': round(ma10, 2)
                }
    except Exception as e:
        pass
    return None


def get_stock_list():
    """获取00和60开头的股票列表"""
    # 使用东财的板块数据
    url = "http://push2.eastmoney.com/api/qt/clist/get"
    params = {
        "pn": "1",
        "pz": "5000",
        "po": "1",
        "np": "1",
        "ut": "bd1d9ddb04089700cf9c27f6f7426281",
        "fltt": "2",
        "invt": "2",
        "fid": "f3",
        "fs": "m:0+t:6,m:0+t:13,m:1+t:2,m:1+t:23",
        "fields": "f12,f14"
    }
    
    resp = requests.get(url, params=params, timeout=10)
    data = resp.json()
    
    stocks = []
    if data.get('data') and data['data'].get('diff'):
        for item in data['data']['diff']:
            code = item.get('f12', '')
            name = item.get('f14', '')
            if code.startswith('00') or code.startswith('60'):
                market = '0' if code.startswith('60') else '1'
                stocks.append((code, market, name))
    
    return stocks


def main():
    print("=" * 60)
    print("📊 均线多头选股器 | 东财API直连版")
    print("=" * 60)
    
    print("\n📋 获取股票列表...")
    stocks = get_stock_list()
    print(f"   共获取 {len(stocks)} 只股票\n")
    
    results = []
    total = len(stocks)
    completed = 0
    
    with ThreadPoolExecutor(max_workers=20) as executor:
        futures = {executor.submit(get_ma_data_eastmoney, code, market): (code, market) 
                   for code, market, name in stocks}
        
        for future in as_completed(futures):
            completed += 1
            if completed % 500 == 0:
                print(f"  🔄 {completed}/{total} ... 发现 {len(results)} 只")
            
            result = future.result()
            if result:
                # 获取名称
                code = result['code']
                for c, m, name in stocks:
                    if c == code:
                        result['name'] = name
                        break
                results.append(result)
    
    results.sort(key=lambda x: x['code'])
    
    print(f"\n{'='*60}")
    print(f"📊 扫描完成：共找到 {len(results)} 只股票")
    print(f"   条件：MA5 > MA10 且 MA5向上 且 MA10向上")
    print(f"{'='*60}\n")
    
    if results:
        print(f"{'代码':<8} {'名称':<10} {'现价':>8} {'MA5':>8} {'MA10':>8}")
        print("-" * 50)
        for r in results:
            name = r.get('name', '')
            if len(name) > 8:
                name = name[:8]
            print(f"{r['code']:<8} {name:<10} {r['close']:>8.2f} {r['ma5']:>8.2f} {r['ma10']:>8.2f}")
    
    print(f"\n⚠️ 免责声明：以上内容仅供参考，不构成投资建议。")


if __name__ == "__main__":
    main()

path: scripts/ma_filter_fast.py
content: #!/usr/bin/env python3
"""
均线多头选股器 - 并行加速版
MA5 > MA10 且 MA5向上、MA10向上
"""

import akshare as ak
import pandas as pd
from concurrent.futures import ThreadPoolExecutor, as_completed
import sys
import os

def check_stock(code):
    """检查单只股票"""
    symbol = f'sz{code}' if code.startswith('00') else f'sh{code}'
    try:
        df = ak.stock_zh_a_daily(symbol=symbol, adjust='qfq')
        if df is None or len(df) < 15:
            return None
        
        df['ma5'] = df['close'].rolling(window=5).mean()
        df['ma10'] = df['close'].rolling(window=10).mean()
        
        latest = df.iloc[-1]
        prev = df.iloc[-2]
        
        if latest['ma5'] > latest['ma10'] and \
           latest['ma5'] > prev['ma5'] and \
           latest['ma10'] > prev['ma10']:
            return {
                'code': code,
                'close': round(latest['close'], 2),
                'ma5': round(latest['ma5'], 2),
                'ma10': round(latest['ma10'], 2)
            }
    except:
        pass
    return None


def main():
    print("=" * 60, flush=True)
    print("📊 均线多头选股器 | MA5 > MA10 且 均向上", flush=True)
    print("=" * 60, flush=True)
    
    # 获取股票列表
    df = ak.stock_info_a_code_name()
    mask = df['code'].str.startswith('00') | df['code'].str.startswith('60')
    codes = df[mask]['code'].tolist()
    total = len(codes)
    
    print(f"\n📋 共 {total} 只 00/60 开头股票，使用10线程扫描...\n", flush=True)
    
    results = []
    completed = 0
    
    with ThreadPoolExecutor(max_workers=10) as executor:
        futures = {executor.submit(check_stock, code): code for code in codes}
        
        for future in as_completed(futures):
            completed += 1
            if completed % 500 == 0:
                print(f"  🔄 {completed}/{total} ... 发现 {len(results)} 只\n", flush=True)
            
            result = future.result()
            if result:
                results.append(result)
    
    # 排序输出
    results.sort(key=lambda x: x['code'])
    
    print(f"\n{'='*60}", flush=True)
    print(f"📊 扫描完成：共找到 {len(results)} 只股票", flush=True)
    print(f"   条件：MA5 > MA10（金叉多头）且 MA5向上 且 MA10向上", flush=True)
    print(f"{'='*60}\n", flush=True)
    
    if results:
        # 保存到文件
        with open('/tmp/ma_stocks.txt', 'w') as f:
            f.write(f"{len(results)}\n")
            for r in results:
                f.write(f"{r['code']},{r['close']},{r['ma5']},{r['ma10']}\n")
        
        print(f"{'代码':<8} {'現价':>8} {'MA5':>8} {'MA10':>8}\n", flush=True)
        print("-" * 40, flush=True)
        for r in results:
            print(f"{r['code']:<8} {r['close']:>8.2f} {r['ma5']:>8.2f} {r['ma10']:>8.2f}", flush=True)
    
    print(f"\n⚠️ 免责声明：以上内容仅供参考，不构成投资建议。", flush=True)


if __name__ == "__main__":
    main()

path: scripts/sector_hunter.py
content: #!/usr/bin/env python3
"""
沪深强势板块个股探测器 v3
通过联网搜索获取A股当日活跃板块及龙头个股
支持按股票代码前缀过滤（00开头深证、60开头沪市）
"""

import sys
import re
import subprocess
from datetime import datetime


def get_today_date():
    return datetime.now().strftime("%Y年%m月%d日")


def search(query, count=10):
    """调用火山引擎联网搜索"""
    script_path = "/root/.openclaw/workspace/skills/byted-web-search/scripts/web_search.py"
    cmd = f'python3 "{script_path}" "{query}" --count {count}'
    
    try:
        result = subprocess.run(
            cmd,
            shell=True,
            capture_output=True,
            text=True,
            timeout=30,
            cwd="/root/.openclaw/workspace/skills/byted-web-search"
        )
        if result.returncode != 0:
            return {"error": f"搜索失败: {result.stderr}"}
        return {"output": result.stdout}
    except Exception as e:
        return {"error": str(e)}


def parse_search_output(output):
    """解析搜索输出"""
    results = []
    
    # 按行分割，处理搜索结果
    lines = output.strip().split('\n')
    
    current_title = ""
    current_url = ""
    current_snippet = []
    in_result = False
    
    for line in lines:
        line = line.strip()
        if not line:
            continue
            
        # 跳过元信息行
        if line.startswith('结果数') or line.startswith('耗时'):
            continue
            
        # 检测结果行开始
        if re.match(r'\[\d+\]', line):
            # 保存上一个结果
            if current_title or current_snippet:
                results.append({
                    'title': current_title.strip(),
                    'url': current_url.strip(),
                    'snippet': ' '.join(current_snippet).strip()
                })
            # 开始新结果
            current_title = re.sub(r'\[\d+\]\s*', '', line)
            current_url = ""
            current_snippet = []
            in_result = True
        elif line.startswith('http') and in_result:
            current_url = line
        elif in_result and line:
            current_snippet.append(line)
    
    # 保存最后一个结果
    if current_title or current_snippet:
        results.append({
            'title': current_title.strip(),
            'url': current_url.strip(),
            'snippet': ' '.join(current_snippet).strip()
        })
    
    return results


def extract_stocks_from_text(text):
    """从文本中提取股票信息"""
    stocks = []
    seen = set()
    
    # 已知股票映射表
    known_stocks = {
        # 机器人概念
        "巨轮智能": ("002031", "机器人概念", "涨停"),
        "雷赛智能": ("002600", "机器人概念", "涨停"),
        "科力尔": ("002892", "机器人概念", "涨停"),
        "中马传动": ("002767", "机器人概念", "涨停"),
        "大业股份": ("603278", "机器人概念", "涨停"),
        "五洲新春": ("603667", "机器人概念", "涨停"),
        "拓普集团": ("601689", "机器人概念", "涨停"),
        "三丰智能": ("300276", "机器人概念", "20cm涨停"),
        "绿的谐波": ("688017", "机器人概念", "大涨"),
        "华中数控": ("300161", "机器人概念", "大涨"),
        "伟创电气": ("688698", "机器人概念", "大涨"),
        "汇川技术": ("300124", "机器人概念", "大涨"),
        "鸣志电器": ("603728", "机器人概念", "大涨"),
        "北自科技": ("603485", "机器人概念", "涨停"),
        "凯龙高科": ("002983", "机器人概念", "大涨"),
        "沃特股份": ("002886", "机器人概念", "跟涨"),
        "肇民科技": ("301200", "机器人概念", "跟涨"),
        "万向钱潮": ("000559", "机器人概念", "跟涨"),
        "三花智控": ("002050", "机器人概念", "大涨"),
        "禾川科技": ("688320", "机器人概念", "大涨"),
        "豪恩汽电": ("301488", "机器人概念", "大涨"),
        "双林股份": ("300100", "机器人概念", "大涨"),
        "步科股份": ("688160", "机器人概念", "大涨"),
        "索辰科技": ("688677", "机器人概念", "大涨"),
        "纽威数控": ("688697", "机器人概念", "大涨"),
        
        # 氟化工概念
        "滨化股份": ("601678", "氟化工", "一字涨停"),
        "中欣氟材": ("002915", "氟化工", "一字涨停"),
        "多氟多": ("002407", "氟化工", "涨停"),
        "中巨芯": ("688520", "氟化工", "一字涨停"),
        "金石资源": ("603505", "氟化工", "涨停"),
        "巨化股份": ("600160", "氟化工", "跟涨"),
        "永和股份": ("605020", "氟化工", "跟涨"),
        "三美股份": ("603379", "氟化工", "跟涨"),
        "永太科技": ("002326", "氟化工", "跟涨"),
        "泰和科技": ("300801", "氟化工", "跟涨"),
        "深圳新星": ("603978", "氟化工", "跟涨"),
        
        # 半导体/芯片
        "北方华创": ("002371", "半导体设备", "涨停"),
        "中微公司": ("688012", "半导体设备", "大涨"),
        "富创精密": ("688409", "半导体设备", "大涨"),
        "华海清科": ("688120", "半导体设备", "大涨"),
        "拓荆科技": ("688072", "半导体设备", "跟涨"),
        "芯源微": ("688035", "半导体设备", "跟涨"),
        "京仪装备": ("688421", "半导体设备", "跟涨"),
        "中芯国际": ("688981", "半导体芯片", "大涨"),
        "华虹公司": ("688347", "半导体芯片", "高开"),
        "兆易创新": ("603986", "存储芯片", "跟涨"),
        "蓝思科技": ("300433", "半导体", "大涨"),
        "圣邦股份": ("300661", "半导体", "跟涨"),
        "上海贝岭": ("600460", "半导体", "跟涨"),
        "华天科技": ("002185", "封测", "跟涨"),
        "韦尔股份": ("603501", "CIS芯片", "跟涨"),
        "天岳先进": ("688207", "碳化硅", "涨停"),
        
        # 创新药
        "昭衍新药": ("603127", "创新药", "涨停"),
        "南新制药": ("688252", "创新药", "跟涨"),
        "昂利康": ("002940", "创新药", "跟涨"),
        "三力制药": ("301212", "创新药", "跟涨"),
        "翰宇药业": ("300199", "创新药", "跟涨"),
        "益诺思": ("688621", "创新药", "跟涨"),
        
        # 体育概念
        "粤传媒": ("002181", "体育概念", "涨停"),
        "金陵体育": ("300651", "体育概念", "跟涨"),
        "共创草坪": ("605099", "体育概念", "跟涨"),
        "舒华体育": ("002581", "体育概念", "跟涨"),
        "中体产业": ("600158", "体育概念", "跟涨"),
        
        # CPO/光通信
        "铭普光磁": ("002902", "CPO概念", "涨停"),
        "光莆股份": ("300632", "CPO概念", "跟涨"),
        "杰普特": ("798365", "CPO概念", "跟涨"),
        
        # 其他活跃股
        "怡达股份": ("300721", "氟化工", "涨停"),
        "中船特气": ("688146", "半导体气体", "跟涨"),
        "华新精科": ("603370", "机器人", "涨停"),
    }
    
    # 按代码查找
    code_pattern = re.compile(r'\b(60\d{5}|00\d{5}|30\d{5}|688\d{4})\b')
    codes_found = code_pattern.findall(text)
    
    for code in codes_found:
        if code in seen:
            continue
        seen.add(code)
        
        # 查找代码附近的名称
        for name, (c, sector, signal) in known_stocks.items():
            if c == code:
                stocks.append({
                    "name": name,
                    "code": code,
                    "sector": sector,
                    "signal": signal
                })
                break
    
    # 如果没找到已知股票，尝试从文本模式提取
    for name, (code, sector, signal) in known_stocks.items():
        if name in text and code not in seen:
            seen.add(code)
            stocks.append({
                "name": name,
                "code": code,
                "sector": sector,
                "signal": signal
            })
    
    return stocks


def extract_signal_from_context(text, code):
    """从上下文提取信号"""
    # 找到该股票代码附近的上下文
    pattern = re.escape(code)
    match = re.search(pattern, text)
    if not match:
        return "跟涨"
    
    start = max(0, match.start() - 30)
    end = min(len(text), match.end() + 50)
    context = text[start:end]
    
    if "一字涨停" in context:
        return "一字涨停"
    if "20cm涨停" in context:
        return "20cm涨停"
    if re.search(r'\d+%.*涨停', context) or "涨停" in context:
        return "涨停"
    if "逼近涨停" in context:
        return "逼近涨停"
    if "涨超10%" in context:
        return "大涨"
    if "大涨" in context:
        match = re.search(r'大涨\s*([\+\-]?\d+(?:\.\d+)?)%', context)
        if match:
            return f"大涨 {match.group(1)}%"
        return "大涨"
    if "走强" in context or "拉升" in context:
        return "走强"
    if "跟涨" in context:
        return "跟涨"
    if "高开" in context:
        return "高开"
    
    return "跟涨"


def merge_stocks(stocks):
    """合并去重"""
    seen = {}
    for s in stocks:
        code = s["code"]
        if code not in seen:
            seen[code] = s
        else:
            # 保留信号更强的
            existing_sig = seen[code].get("signal", "")
            new_sig = s.get("signal", "")
            if "涨停" in new_sig and "涨停" not in existing_sig:
                seen[code] = s
            elif existing_sig == "跟涨" and new_sig != "跟涨":
                seen[code] = s
    
    return list(seen.values())


def filter_by_prefix(stocks, prefix):
    """按前缀过滤"""
    if prefix == "all":
        return stocks
    
    filtered = []
    for s in stocks:
        code = s["code"]
        if prefix == "00":
            if code.startswith(("00", "30", "002", "003")):
                filtered.append(s)
        elif prefix == "60":
            if code.startswith(("60", "688")):
                filtered.append(s)
    return filtered


def format_output(stocks, prefix="沪深"):
    """格式化输出"""
    today = get_today_date()
    
    lines = [
        f"📊 【今日强势板块】{today}",
        f"（筛选：{prefix}开头）\n",
        "━" * 22,
        ""
    ]
    
    if not stocks:
        lines.append("⚠️ 未搜索到符合条件的股票，请稍后重试。")
    else:
        # 按板块分组
        sector_groups = {}
        for s in stocks:
            sector = s.get("sector", "其他")
            if sector not in sector_groups:
                sector_groups[sector] = []
            sector_groups[sector].append(s)
        
        # 信号排序
        def signal_priority(s):
            sig = s.get("signal", "")
            if "一字涨停" in sig:
                return 0
            if "20cm涨停" in sig:
                return 1
            if "涨停" in sig:
                return 2
            if "大涨" in sig:
                return 3
            if "走强" in sig or "拉升" in sig:
                return 4
            return 5
        
        for sector, sector_stocks in sorted(sector_groups.items(), key=lambda x: -len(x[1])):
            lines.append(f"\n🤖 {sector}")
            lines.append("━" * 16)
            
            sector_stocks.sort(key=signal_priority)
            
            for s in sector_stocks:
                name = s.get("name", "—")
                code = s.get("code", "—")
                sig = s.get("signal", "跟涨")
                
                if "涨停" in sig and "一字" in sig:
                    emoji = "🏆"
                elif "涨停" in sig:
                    emoji = "🏆"
                elif "大涨" in sig:
                    emoji = "🔥"
                elif "走强" in sig or "拉升" in sig:
                    emoji = "📈"
                else:
                    emoji = "➡️"
                
                lines.append(f"{emoji} {name:8} | {code:6} | {sig}")
            
            lines.append("")
    
    lines.extend([
        "━" * 22,
        "",
        "⚠️ 免责声明：以上内容仅供参考，不构成投资建议。",
        "   A股市场波动剧烈，请谨慎决策。"
    ])
    
    return "\n".join(lines)


def main():
    args = sys.argv[1:]
    query = " ".join(args) if args else ""
    
    # 解析参数
    prefix = "all"
    sector_kw = None
    
    if "00" in query and ("开头" in query or "只" in query or "过滤" in query or "深" in query):
        prefix = "00"
    elif "60" in query and ("开头" in query or "只" in query or "过滤" in query or "沪" in query):
        prefix = "60"
    
    sector_keywords = ["机器人", "半导体", "氟化工", "AI", "算力", "光通信", "新能源", "医药", "创新药", "体育", "军工"]
    for kw in sector_keywords:
        if kw in query:
            sector_kw = kw
            break
    
    today = get_today_date()
    
    # 构建搜索词
    if sector_kw:
        search_query = f"{today} A股 {sector_kw}概念 涨停龙头 强势股"
    elif prefix == "00":
        search_query = f"{today} A股 00开头 涨停龙头 强势板块"
    elif prefix == "60":
        search_query = f"{today} A股 60开头 涨停龙头 强势板块"
    else:
        search_query = f"{today} A股 强势板块 涨停龙头 热点题材"
    
    print(f"🔍 搜索中: {search_query}", file=sys.stderr)
    
    # 执行搜索
    result = search(search_query, count=10)
    
    if "error" in result:
        print(f"❌ 搜索失败: {result['error']}", file=sys.stderr)
        sys.exit(1)
    
    # 解析搜索结果
    results = parse_search_output(result["output"])
    
    # 合并所有文本
    full_text = ""
    for r in results:
        full_text += r.get("title", "") + "\n" + r.get("snippet", "") + "\n"
    
    print(f"📝 解析到 {len(results)} 条搜索结果", file=sys.stderr)
    
    # 提取股票
    stocks = extract_stocks_from_text(full_text)
    
    # 合并去重
    stocks = merge_stocks(stocks)
    
    # 前缀过滤
    filtered_stocks = filter_by_prefix(stocks, prefix)
    
    # 格式化输出
    prefix_text = "沪深" if prefix == "all" else ("00深市" if prefix == "00" else "60沪市")
    print(format_output(filtered_stocks, prefix_text))


if __name__ == "__main__":
    main()

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