Skill: pandasky/a-share-thermometer (version 1.0.8)

--- name: a-share-thermometer description: 查询A股市场温度。当用户询问"今日市场温度"、"今日A股温度"、"市场热度"、"大盘温度"或类似问题时触发此技能。支持"上证50", "沪深300", "上证380", "创业板50", "中证500", "上证180", "深证红利", "深证100", "中证1000", "上证红利", "中证100", "中证800"。 metadata: author: PeterPan version: "1.0.7" --- # A股市场温度查询 ## 输出格式示例(严格遵守以下格式) ``` 📊 今日A股市场温度报告 (2026-04-20) 指数 PE 温度 状态 上证指数 12.5 25°C 低温 深证成指 18.3 45°C 中温 创业板指 35.2 86°C 高温 ``` ## 注意事项 - 严格按照输出格式示例呈现数据。 - 报告日期修改为当天的东8区日期 - 如果程序报错或无法获取数据，输出相应的错误信息。 - 禁止输出任何与格式无关的文本或解释。 - 禁止输出整体判断、总结或建议。 ## 工作流程 ### 1. 读取配置文件 读取 `scripts/config.json` 配置文件，获取需要计算市场温度的指数列表。 ### 2. 执行Python3脚本 循环调用 `scripts/a_share_therm.py` 脚本，为每个配置的指数获取： - PE(TTM)数据 - 市场温度 脚本接受指数名称作为参数：`python3 scripts/a_share_therm.py --index <指数名称>` ### 3. 判断温度状态 将每个指数的温度划分为以下状态： - 低温 (< 30°C) - 中温 (30°C - 80°C) - 高温 (> 80°C) ## 配置文件说明 `config.json` 结构： ```json { "indices": [ {"code": "000001", "name": "上证指数"}, {"code": "399001", "name": "深证成指"}, {"code": "399006", "name": "创业板指"} ] } ``` 用户可修改 `indices` 数组来自定义监控的指数。温度阈值可根据个人偏好调整。

path: scripts/a_share_therm.py
content: import argparse
import akshare as ak
import pandas as pd
import concurrent.futures
from datetime import date
from dateutil.relativedelta import relativedelta

INDEX_NAMES = [
    "上证50", "沪深300", "上证380", "创业板50",
    "中证500", "深证红利", "深证100", "中证1000",
]

def get_index_temperature(name: str) -> dict:
    try:
        ten_years_ago = date.today() - relativedelta(years=10)
        df = ak.stock_index_pe_lg(name)
        metric = "滚动市盈率"
        df["日期"] = pd.to_datetime(df["日期"])
        df = df[(df["日期"] >= pd.to_datetime(ten_years_ago)) & (df[metric] > 0)].sort_values("日期")
        if len(df) < 250:
            return {"name": name, "error": "数据不足"}
        latest_pe = df[metric].iloc[-1]
        pectile_pe = df[metric].rank(pct=True)[df[metric] == latest_pe]
        temperature = pectile_pe.mean() * 100
        return {"name": name, "pe": round(latest_pe, 2), "temp": round(temperature, 1)}
    except Exception as e:
        return {"name": name, "error": str(e)}

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--index", default=None, help="指数名称")
    args = parser.parse_args()

    if args.index:
        result = get_index_temperature(args.index)
        if "error" in result:
            print(f"指数：{result['name']}\n失败：{result['error']}")
        else:
            print(f"指数：{result['name']}\n当前PE(TTM)：{result['pe']:.2f}\n温度：{result['temp']:.1f}")
    else:
        with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:
            futures = {executor.submit(get_index_temperature, name): name for name in INDEX_NAMES}
            results = []
            for future in concurrent.futures.as_completed(futures):
                results.append(future.result())
        for name in INDEX_NAMES:
            for r in results:
                if r["name"] == name:
                    if "error" in r:
                        print(f"指数：{r['name']}\n失败：{r['error']}\n")
                    else:
                        print(f"指数：{r['name']}\n当前PE(TTM)：{r['pe']:.2f}\n温度：{r['temp']:.1f}\n")
                    break

if __name__ == "__main__":
    main()


path: scripts/config.json
content: {
  "indices": [
    {"code": "000016", "name": "上证50"},
    {"code": "000300", "name": "沪深300"},
    {"code": "000009", "name": "上证380"},
    {"code": "399005", "name": "创业板50"},
    {"code": "000905", "name": "中证500"},
    {"code": "000011", "name": "深证红利"},
    {"code": "000012", "name": "深证100"},
    {"code": "000852", "name": "中证1000"}
  ]
}


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