weekly-performance-digest

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Weekly Performance Digest

每周绩效摘要

Overview

概述

Weekly Performance Digest aggregates the trades you closed during a week into a single performance report. It reads CLOSED theses tracked by
trader-memory-core
(
state/theses/th_*.yaml
), computes headline metrics (win rate, expectancy, profit factor, R-multiple, MAE/MFE), breaks results down across several pattern dimensions (source skill, exit reason, thesis type, sector, mechanism tag, screening grade), and surfaces the week's biggest winners, losers, and lessons. Output is a JSON record plus a human-readable Markdown report. Pure calculation — no API key required.
每周绩效摘要将您一周内平仓的交易汇总成一份绩效报告。它读取由
trader-memory-core
追踪的已平仓交易记录(
state/theses/th_*.yaml
),计算核心指标(胜率、期望收益、利润因子、R-multiple、MAE/MFE),从多个维度(来源skill、退出原因、交易类型(thesis type)、行业、机制标签、筛选等级)拆分结果,并呈现本周的最大盈利、最大亏损及经验教训。输出为JSON记录和易读的Markdown报告。纯计算操作——无需API密钥。

When to Use

使用场景

  • At the end of a trading week to review aggregate realized performance
  • To measure win rate and expectancy across all closed positions
  • To see which source skills, exit reasons, sectors, or mechanisms drove wins vs losses
  • To feed a month-end review (combine four weekly digests) or a postmortem
  • For a quick "what worked / what didn't" snapshot grounded in real closed trades
  • 交易周结束时,复盘整体已实现绩效
  • 衡量所有平仓头寸的胜率和期望收益
  • 查看哪些来源skill、退出原因、行业或机制主导了盈利与亏损
  • 为月末复盘提供数据(合并四份周度摘要)或用于事后分析
  • 获取基于真实平仓交易的快速“有效/无效策略”快照

When Not to Use

不适用场景

  • For a single-trade deep review — use
    trade-performance-coach
  • For signal-level true/false-positive classification — use
    signal-postmortem
  • For buy/sell recommendations or position sizing — this skill is descriptive only
  • 单交易深度复盘——使用
    trade-performance-coach
  • 信号层面的真假阳性分类——使用
    signal-postmortem
  • 买卖建议或头寸规模计算——本skill仅作描述性分析

Prerequisites

前置条件

  • Python 3.9+ with
    PyYAML
    (already a repo dependency)
  • A
    trader-memory-core
    state directory of thesis YAML files (
    state/theses/
    )
  • No API key required
  • Python 3.9+ 及
    PyYAML
    (已作为仓库依赖项)
  • 包含交易记录YAML文件的
    trader-memory-core
    状态目录(
    state/theses/
  • 无需API密钥

Workflow

工作流程

Step 1: Run the digest for a week

步骤1:生成某一周的绩效摘要

bash
python3 skills/weekly-performance-digest/scripts/generate_weekly_digest.py \
  --state-dir state/theses \
  --from-date 2026-06-13 --to-date 2026-06-20 \
  --output-dir reports/ -v
Defaults:
--state-dir state/theses
,
--from-date
= 7 days before
--to-date
,
--to-date
= today,
--output-dir reports/
. With no date flags it digests the trailing 7 days.
bash
python3 skills/weekly-performance-digest/scripts/generate_weekly_digest.py \
  --state-dir state/theses \
  --from-date 2026-06-13 --to-date 2026-06-20 \
  --output-dir reports/ -v
默认参数:
--state-dir state/theses
--from-date
=
--to-date
前7天,
--to-date
= 今日,
--output-dir reports/
。若未指定日期参数,则默认分析过去7天的数据。

Step 2: Read the report

步骤2:查看报告

The run writes
reports/weekly_digest_<to-date>.json
and
reports/weekly_digest_<to-date>.md
. Review the Markdown for the executive summary, metrics table, pattern breakdowns, and top winners/losers; consume the JSON downstream.
运行后会生成
reports/weekly_digest_<to-date>.json
reports/weekly_digest_<to-date>.md
。查看Markdown报告获取执行摘要、指标表格、模式细分及最大盈利/亏损记录;JSON文件可用于下游处理。

Step 3 (optional): Feed downstream

步骤3(可选):下游处理

Combine several weekly JSON digests for a monthly review, or pass the JSON to a postmortem/coach step. The skill is descriptive — act on its findings via your normal review process.
合并多份周度JSON摘要用于月度复盘,或将JSON文件传入事后分析/指导步骤。本skill仅作描述性分析——需通过您的常规复盘流程根据分析结果采取行动。

How It Works

工作原理

  • Trade selection. A trade counts in a week if its
    exit.actual_date
    falls in
    [from-date, to-date]
    and
    status == CLOSED
    .
  • Win/loss.
    outcome.pnl_dollars > 0
    is a winner,
    < 0
    a loser,
    == 0
    breakeven;
    win_rate = winners / total_trades
    .
  • R-multiple.
    pnl_dollars / ((entry.actual_price − exit.stop_loss) × position.shares)
    . (Stop-loss is read from
    exit.stop_loss
    , per the real thesis schema.)
  • Double-counting safeguard. A CLOSED thesis's
    outcome.pnl_dollars
    is the cumulative realized P&L across all trims plus the final leg. Headline metrics use that cumulative value over CLOSED theses only. The separate
    partial_trims
    block scans
    status_history[]
    of PARTIALLY_CLOSED theses only (still open) and is reported for information — it is never added into the headline totals/win-rate. A position trimmed in week 1 then closed in week 2 therefore shows as a partial trim in week 1 and inside week 2's CLOSED headline; that is intended, not a duplicate.
  • 交易筛选:若交易的
    exit.actual_date
    落在
    [from-date, to-date]
    区间且
    status == CLOSED
    ,则计入当周统计。
  • 盈亏判定
    outcome.pnl_dollars > 0
    为盈利,
    < 0
    为亏损,
    == 0
    为盈亏平衡;
    win_rate = 盈利交易数 / 总交易数
  • R-multiple
    pnl_dollars / ((entry.actual_price − exit.stop_loss) × position.shares)
    。(止损价取自
    exit.stop_loss
    ,遵循真实交易记录 schema。)
  • 重复计数防护:已平仓交易记录的
    outcome.pnl_dollars
    是所有分批平仓加上最终平仓的累计已实现盈亏。核心指标仅使用已平仓交易记录的该累计值。单独的
    partial_trims
    模块仅扫描**PARTIALLY_CLOSED(仍持仓)**交易记录的
    status_history[]
    ,仅作信息展示——绝不会计入核心指标的总数/胜率。因此,第1周分批平仓、第2周全部平仓的头寸会在第1周显示为分批平仓记录,在第2周计入核心指标;此为预期设计,并非重复计数。

Output Format

输出格式

JSON (
weekly_digest_<to-date>.json
)

JSON(
weekly_digest_<to-date>.json

json
{
  "schema_version": "1.0",
  "report_type": "weekly_performance_digest",
  "period": {"from": "2026-06-13", "to": "2026-06-20"},
  "generated_at": "2026-06-20T21:39:07Z",
  "summary": {
    "total_trades": 2, "winners": 1, "losers": 1, "breakeven": 0,
    "win_rate": 0.5, "expectancy": 25.0, "profit_factor": 2.0,
    "total_realized_pnl": 50.0, "total_realized_pnl_pct": 4.17
  },
  "metrics": {
    "avg_winner": 100.0, "avg_loser": -50.0,
    "largest_winner": 100.0, "largest_loser": -50.0,
    "avg_holding_days_winners": 9.0, "avg_holding_days_losers": 6.0,
    "r_multiple_avg": 0.25, "r_multiple_stdev": 1.06,
    "avg_mae_pct": -3.75, "avg_mfe_pct": 4.5
  },
  "pattern_analysis": {
    "by_source_skill": {"...": {"wins": 1, "losses": 0, "total": 1, "win_rate": 1.0}},
    "by_exit_reason": {}, "by_thesis_type": {}, "by_sector": {},
    "by_mechanism_tag": {}, "by_screening_grade": {}
  },
  "partial_trims": {"count": 0, "total_realized_pnl": 0.0, "trims": []},
  "lessons": {"top_wins": [], "top_losses": [], "process_improvements": []}
}
json
{
  "schema_version": "1.0",
  "report_type": "weekly_performance_digest",
  "period": {"from": "2026-06-13", "to": "2026-06-20"},
  "generated_at": "2026-06-20T21:39:07Z",
  "summary": {
    "total_trades": 2, "winners": 1, "losers": 1, "breakeven": 0,
    "win_rate": 0.5, "expectancy": 25.0, "profit_factor": 2.0,
    "total_realized_pnl": 50.0, "total_realized_pnl_pct": 4.17
  },
  "metrics": {
    "avg_winner": 100.0, "avg_loser": -50.0,
    "largest_winner": 100.0, "largest_loser": -50.0,
    "avg_holding_days_winners": 9.0, "avg_holding_days_losers": 6.0,
    "r_multiple_avg": 0.25, "r_multiple_stdev": 1.06,
    "avg_mae_pct": -3.75, "avg_mfe_pct": 4.5
  },
  "pattern_analysis": {
    "by_source_skill": {"...": {"wins": 1, "losses": 0, "total": 1, "win_rate": 1.0}},
    "by_exit_reason": {}, "by_thesis_type": {}, "by_sector": {},
    "by_mechanism_tag": {}, "by_screening_grade": {}
  },
  "partial_trims": {"count": 0, "total_realized_pnl": 0.0, "trims": []},
  "lessons": {"top_wins": [], "top_losses": [], "process_improvements": []}
}

Markdown (
weekly_digest_<to-date>.md
)

Markdown(
weekly_digest_<to-date>.md

Sections:
# Weekly Performance Digest
,
## Executive Summary
,
## Performance Metrics
,
## Pattern Analysis
,
## Lessons Learned
(
### Top Winners
/
### Top Losers
/
### Process Improvements
).
An empty week still produces a valid report with zeroed metrics (exit code 0).
包含章节:
# 每周绩效摘要
## 执行摘要
## 绩效指标
## 模式分析
## 经验教训
### 最大盈利
/
### 最大亏损
/
### 流程改进建议
)。
空交易周仍会生成指标全为0的有效报告(退出码为0)。

Resources

资源

  • scripts/generate_weekly_digest.py
    — digest generator (JSON + Markdown)
  • references/weekly-digest-metrics.md
    — metric formulas and interpretation
  • scripts/generate_weekly_digest.py
    —— 摘要生成器(JSON + Markdown)
  • references/weekly-digest-metrics.md
    —— 指标公式及解读

Key Principles

核心原则

  1. Closed trades only for headline numbers — cumulative
    outcome.*
    , keyed on exit date.
  2. No double-counting — partial trims are informational and excluded from totals.
  3. Pattern attribution — every win/loss is attributed across multiple dimensions.
  4. Descriptive, not prescriptive — the digest reports; you decide.
  1. 核心指标仅统计已平仓交易——累计
    outcome.*
    ,按平仓日期统计。
  2. 无重复计数——分批平仓记录仅作信息展示,不计入总数。
  3. 模式归因——每笔盈亏均从多个维度进行归因分析。
  4. 仅作描述,不提供指令——摘要仅作报告,决策由您自行做出。