Community编程与开发github.com

信号事后分析

记录和分析边缘管线及其他技能生成的交易信号的事后结果。跟踪误报、错失机会和机制不匹配,并将结果反馈给边缘信号聚合器权重调整和技能改进待办事项。

信号事后分析 是什么?

Signal Postmortem 技能旨在系统性地记录和分析由边缘管线、筛选器和其他技能生成的交易信号的实际表现。该技能通过将预测的方向(多头或空头)与5天和20天的实际回报进行比较,将每个信号的结果分类为真阳性、假阳性、错失机会或机制不匹配之一。其核心价值在于形成一个闭环反馈:分析结果可用于生成边缘信号聚合器的权重调整建议,从而优化信号组合;同时,也会创建技能改进待办项,帮助开发团队识别并解决特定技能的假阳性或机制相关缺陷。该技能支持通过命令行手动输入退出价格和日期,或通过可选的FMP API密钥自动获取价格数据以计算回报。它生成结构化的JSON、YAML和Markdown报告,包括详细的事后记录、权重反馈和汇总统计,适用于任何能生成JSON格式信号的系统,如边缘信号聚合器或筛选器。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/tradermonty/claude-trading-skills/tree/main/skills/signal-postmortem

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

信号事后分析 是做什么的?

概述

信号事后分析记录并分析由边缘管线、筛选器及其他技能生成的交易信号的结果。它将预测的方向与5天和20天的实际回报进行比较,将结果分类(真阳性、假阳性、错失机会、机制不匹配),并生成用于边缘信号聚合器权重调整和技能改进待办事项的反馈。

何时使用

  • 交易平仓后,需要记录结果时
  • 当审查一批已达到持有期(5或20天)的信号时
  • 识别来自特定技能的系统性假阳性模式时
  • 为边缘信号聚合器的权重校准生成反馈时
  • 从决策质量指标构建技能改进待办事项时
  • 定期(每周/每月)进行信号质量审计时

先决条件

  • Python 3.9+
  • FMP API密钥(可选,如果不手动提供退出价格,用于获取实际回报)
  • 标准库 + requests 用于API调用
  • 输入:JSON格式的信号记录(来自边缘信号聚合器或筛选器输出)

API密钥设置(可选)

如果要自动获取价格数据进行回报计算,请设置FMP API密钥:

export FMP_API_KEY=your_api_key_here

或者,通过命令行使用 --api-key YOUR_KEY 传递密钥。如果没有API密钥,您仍然可以通过提供 --exit-price 和 --exit-date 手动记录结果。

工作流程

第1步:准备信号记录

收集已关闭或已到期的信号记录。每条记录应包含:

  • signal_id:唯一标识符
  • ticker:股票代码
  • signal_date:信号生成日期
  • predicted_direction:多头或空头
  • source_skill:哪个技能生成了该信号
  • entry_price:信号生成时的价格(可选,用于手动覆盖)
# 示例:列出已准备好进行事后分析的信号(5天以上)
python3 skills/signal-postmortem/scripts/postmortem_recorder.py \
  --list-ready \
  --signals-dir state/signals/ \
  --min-days 5

第2步:记录结果

运行事后记录器以获取实际回报并对结果进行分类。

python3 skills/signal-postmortem/scripts/postmortem_recorder.py \
  --signals-file state/signals/aggregated_signals_2026-03-10.json \
  --holding-periods 5,20 \
  --output-dir reports/

手动记录结果(当价格数据已可用时):

python3 skills/signal-postmortem/scripts/postmortem_recorder.py \
  --signal-id sig_aapl_20260310_abc \
  --exit-price 178.50 \
  --exit-date 2026-03-15 \
  --outcome-notes "在目标位平仓,5天内+3.2%" \
  --output-dir reports/

第3步:分类结果

记录器自动将每个信号分类为以下四个类别之一:

类别定义
TRUE_POSITIVE预测方向与实际回报符号一致
FALSE_POSITIVE预测方向与实际回报相反
MISSED_OPPORTUNITY信号未被采纳但本来会有利润
REGIME_MISMATCH由于市场机制变化导致信号失败

分类规则记录在 references/outcome-classification.md 中。

第4步:生成反馈文件

为下游消费者生成反馈:

# 生成边缘信号聚合器的权重调整建议
python3 skills/signal-postmortem/scripts/postmortem_analyzer.py \
  --postmortems-dir reports/postmortems/ \
  --generate-weight-feedback \
  --output-dir reports/

# 生成技能改进待办项
python3 skills/signal-postmortem/scripts/postmortem_analyzer.py \
  --postmortems-dir reports/postmortems/ \
  --generate-improvement-backlog \
  --output-dir reports/

第5步:审查汇总统计

生成按技能、按股票代码和按时间段的汇总统计:

python3 skills/signal-postmortem/scripts/postmortem_analyzer.py \
  --postmortems-dir reports/postmortems/ \
  --summary \
  --group-by skill,month \
  --output-dir reports/

输出格式

事后记录(JSON)

{
  "schema_version": "1.0",
  "postmortem_id": "pm_sig_aapl_20260310_abc",
  "signal_id": "sig_aapl_20260310_abc",
  "ticker": "AAPL",
  "signal_date": "2026-03-10",
  "source_skill": "edge-signal-aggregator",
  "predicted_direction": "LONG",
  "entry_price": 172.50,
  "realized_returns": {
    "5d": 0.032,
    "20d": 0.058
  },
  "exit_price": 178.50,
  "exit_date": "2026-03-15",
  "holding_days": 5,
  "outcome_category": "TRUE_POSITIVE",
  "regime_at_signal": "RISK_ON",
  "regime_at_exit": "RISK_ON",
  "outcome_notes": "干净突破,在轻微回调后持有",
  "recorded_at": "2026-03-17T10:30:00Z"
}

权重反馈(JSON)

{
  "schema_version": "1.0",
  "generated_at": "2026-03-17T10:35:00Z",
  "analysis_period": {
    "from": "2026-02-01",
    "to": "2026-03-15"
  },
  "skill_adjustments": [
    {
      "skill": "vcp-screener",
      "current_weight": 1.0,
      "suggested_weight": 0.85,
      "reason": "在RISK_OFF机制下假阳性率为15%",
      "sample_size": 42
    }
  ],
  "confidence": "MEDIUM",
  "min_sample_threshold": 20
}

技能改进待办项(YAML)

- skill: vcp-screener
  issue_type: false_positive_cluster
  severity: medium
  evidence:
    false_positive_rate: 0.15
    sample_size: 42
    regime_correlation: RISK_OFF
  suggested_action: "添加机制过滤器或在RISK_OFF机制下降低信号信心"
  generated_by: signal-postmortem
  generated_at: "2026-03-17T10:35:00Z"

汇总报告(Markdown)

报告保存到 reports/ 目录,文件名格式为 postmortem_summary_YYYY-MM-DD.md。

资源

  • scripts/postmortem_recorder.py -- 记录单个信号结果
  • scripts/postmortem_analyzer.py -- 生成反馈和汇总统计
  • references/outcome-classification.md -- 分类规则和边界情况
  • references/feedback-integration.md -- 如何将反馈集成到下游技能

关键原则

  1. 诚实归因 -- 每个结果都归属于其来源技能,以确保可问责性
  2. 机制感知 -- 记录机制上下文,以区分技能失败与市场机制转变
  3. 最小样本量 -- 权重调整至少需要20个信号以确保统计有效性
  4. 反馈闭环 -- 结果反馈用于改进信号聚合和技能质量

Individual skills in this repo

This repo contains 14 individual skills — each has its own dedicated page.

tradermonty/backtest-expert

Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.

tradermonty/market-environment-analysis

Comprehensive market environment analysis and reporting tool. Analyzes global markets including US, European, Asian markets, forex, commodities, and economic indicators. Provides risk-on/risk-off assessment, sector analysis, and technical indicator interpretation. Triggers on keywords like market analysis, market environment, global markets, trading environment, market conditions, investment climate, market sentiment, forex analysis, stock market analysis, 相場環境, 市場分析, マーケット状況, 投資環境.

tradermonty/market-news-analyst

This skill should be used when analyzing recent market-moving news events and their impact on equity markets and commodities. Use this skill when the user requests analysis of major financial news from the past 10 days, wants to understand market reactions to monetary policy decisions (FOMC, ECB, BOJ), needs assessment of geopolitical events' impact on commodities, or requires comprehensive review of earnings announcements from mega-cap stocks. The skill automatically collects news using WebSearch/WebFetch tools and produces impact-ranked analysis reports. All analysis thinking and output are conducted in English.

tradermonty/options-strategy-advisor

Options trading strategy analysis and simulation tool. Provides theoretical pricing using Black-Scholes model, Greeks calculation, strategy P/L simulation, and risk management guidance. Use when user requests options strategy analysis, covered calls, protective puts, spreads, iron condors, earnings plays, or options risk management. Includes volatility analysis, position sizing, and earnings-based strategy recommendations. Educational focus with practical trade simulation.

tradermonty/portfolio-manager

Comprehensive portfolio analysis using Alpaca MCP Server integration to fetch holdings and positions, then analyze asset allocation, risk metrics, individual stock positions, diversification, and generate rebalancing recommendations. Use when user requests portfolio review, position analysis, risk assessment, performance evaluation, or rebalancing suggestions for their brokerage account.

tradermonty/scenario-analyzer

Skill that analyzes 18-month scenarios from a news headline. Runs the primary analysis with the scenario-analyst agent and obtains a second opinion with the strategy-reviewer agent. Generates a comprehensive English report covering 1st/2nd/3rd-order impacts, recommended stocks, and a critical review. Example: /scenario-analyzer "Fed raises rates by 50bp" Triggers: news analysis, scenario analysis, 18-month outlook, medium-to-long-term investment strategy

tradermonty/sector-analyst

This skill should be used when analyzing sector rotation patterns and market cycle positioning. It fetches sector uptrend data from CSV (no API key required) and optionally accepts chart images for supplementary analysis. Use this skill when the user requests sector rotation analysis, cyclical vs defensive assessment, overbought/oversold identification, or market cycle phase estimation. All analysis and output are conducted in English.

tradermonty/skill-designer

Design new Claude skills from structured idea specifications. Use when the skill auto-generation pipeline needs to produce a Claude CLI prompt that creates a complete skill directory (SKILL.md, references, scripts, tests) following repository conventions.

tradermonty/skill-idea-miner

Mine Claude Code session logs for skill idea candidates. Use when running the weekly skill generation pipeline to extract, score, and backlog new skill ideas from recent coding sessions.

tradermonty/theme-detector

Detect and analyze trending market themes across sectors. Use when user asks about current market themes, trending sectors, sector rotation, thematic investing, what themes are hot or cold, or wants to identify bullish and bearish market narratives with lifecycle analysis.

tradermonty/uptrend-analyzer

Analyzes market breadth using Monty's Uptrend Ratio Dashboard data to diagnose the current market environment. Generates a 0-100 composite score from 5 components (breadth, sector participation, rotation, momentum, historical context). Use when asking about market breadth, uptrend ratios, or whether the market environment supports equity exposure. No API key required.

tradermonty/us-stock-analysis

Comprehensive US stock analysis including fundamental analysis (financial metrics, business quality, valuation), technical analysis (indicators, chart patterns, support/resistance), stock comparisons, and investment report generation. Use when user requests analysis of US stock tickers (e.g., "analyze AAPL", "compare TSLA vs NVDA", "give me a report on Microsoft"), evaluation of financial metrics, technical chart analysis, or investment recommendations for American stocks.

tradermonty/value-dividend-screener

Screen US stocks for high-quality dividend opportunities combining value characteristics (P/E ratio under 20, P/B ratio under 2), attractive yields (3% or higher), and consistent growth (dividend/revenue/EPS trending up over 3 years). Supports two-stage screening using FINVIZ Elite API for efficient pre-filtering followed by FMP API for detailed analysis. Use when user requests dividend stock screening, income portfolio ideas, or quality value stocks with strong fundamentals.

tradermonty/vcp-screener

Screen S&P 500 stocks for Mark Minervini's Volatility Contraction Pattern (VCP) and detect historical VCPs in a single ticker's price path. Identifies Stage 2 uptrend stocks forming tight bases with contracting volatility near breakout pivot points; in historical single-ticker mode walks a multi-year history and emits every VCP that formed with forward-outcome stats (breakout / stop-hit / timeout). Use when user requests VCP screening, Minervini-style setups, tight base patterns, volatility contraction breakout candidates, Stage 2 momentum stock scanning, or historical VCP pattern study on a specific ticker (e.g. FIX, TSLA).

相关技能