pre-trade-discipline-gate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Pre-Trade Discipline Gate

交易前纪律校验门

Overview

概述

Evaluate whether a planned manual order should proceed before it is placed at the broker. This skill reads a local checklist plus optional market-regime, circuit-breaker, and trader-memory-core artifacts. It produces a
pre_trade_discipline_decision
artifact and can link that artifact back to the related thesis without changing the thesis review schedule.
The gate is intentionally offline. It does not place orders, cancel orders, call a broker API, or fetch market data.
评估计划中的手动订单是否应在提交给经纪商前执行。该Skill会读取本地检查清单以及可选的市场机制、熔断机制和trader-memory-core工件。它会生成一个
pre_trade_discipline_decision
工件,并可将该工件关联到相关的交易论点(thesis),而不会改变论点的审核日程。
该校验门为离线设计,不会下单、取消订单、调用经纪商API或获取市场数据。

When to Use

使用场景

  • Immediately before placing any manual entry order
  • When a candidate has passed chart validation and position sizing
  • After a recent loss, to avoid revenge trades during the cooldown window
  • When the workflow has an upstream
    exposure_decision
    and
    circuit_breaker_decision
  • When you want checklist adherence to be visible in later trader-memory-core reviews
  • 下达任何手动入场订单前立即使用
  • 当候选订单通过图表验证和仓位规模确认后
  • 近期出现亏损后,用于避免冷却期内的报复性交易
  • 工作流上游存在
    exposure_decision
    circuit_breaker_decision
  • 希望检查清单的遵守情况在后续trader-memory-core审核中可见时

Prerequisites

前置条件

  • Python 3.9+
  • A local JSON or YAML answers file with candidate-level checklist answers
  • Optional trader-memory-core thesis state under
    state/theses/
  • Optional
    exposure_decision
    JSON from market-regime-daily / exposure-coach
  • Optional
    circuit_breaker_decision
    JSON from drawdown-circuit-breaker
  • Python 3.9+
  • 包含候选订单级检查清单答案的本地JSON或YAML文件
  • 可选:
    state/theses/
    下的trader-memory-core交易论点状态
  • 可选:来自market-regime-daily / exposure-coach的
    exposure_decision
    JSON文件
  • 可选:来自drawdown-circuit-breaker的
    circuit_breaker_decision
    JSON文件

Workflow

工作流程

Step 1: Prepare the Checklist

步骤1:准备检查清单

Create a JSON or YAML file with candidate answers. Only actionable manual-order intents are gated. Watchlist and ignore intents are journaled as
NO_ACTIONABLE_ORDERS
.
json
{
  "candidates": [
    {
      "symbol": "AAPL",
      "thesis_id": "th_aapl_gm_20260703_0001",
      "order_intent": "ENTRY_READY",
      "entry_in_written_plan": true,
      "stop_predefined": true,
      "size_within_plan": true,
      "planned_risk_dollars": 500,
      "actual_risk_dollars": 500,
      "notes": "Entry matches the journaled breakout plan."
    }
  ]
}
Actionable intents are
ENTRY_READY
,
ACTIONABLE
,
ACTIONABLE_DAY1
, and
MANUAL_ORDER
. Non-actionable intents such as
WATCHLIST
,
DELAYED_EP_WATCH
,
PEAD_HANDOFF
,
IGNORE
, and
REJECTED
are recorded but do not create an order permission.
Provide both
planned_risk_dollars
and
actual_risk_dollars
for every actionable candidate. Use a finite, non-negative number or numeric string; zero is valid. Treat missing values, booleans, non-numeric strings,
NaN
, infinities, and negative values as
REVIEW_REQUIRED
inputs and review them before placing an order.
创建包含候选订单答案的JSON或YAML文件。仅对可执行的手动订单意向进行校验。观察列表和忽略意向会被记录为
NO_ACTIONABLE_ORDERS
json
{
  "candidates": [
    {
      "symbol": "AAPL",
      "thesis_id": "th_aapl_gm_20260703_0001",
      "order_intent": "ENTRY_READY",
      "entry_in_written_plan": true,
      "stop_predefined": true,
      "size_within_plan": true,
      "planned_risk_dollars": 500,
      "actual_risk_dollars": 500,
      "notes": "Entry matches the journaled breakout plan."
    }
  ]
}
可执行意向包括
ENTRY_READY
ACTIONABLE
ACTIONABLE_DAY1
MANUAL_ORDER
。非可执行意向如
WATCHLIST
DELAYED_EP_WATCH
PEAD_HANDOFF
IGNORE
REJECTED
会被记录,但不会生成下单权限。
为每个可执行候选订单同时提供
planned_risk_dollars
actual_risk_dollars
。使用有限的非负数或数字字符串;零是有效的。将缺失值、布尔值、非数字字符串、
NaN
、无穷大和负值视为
REVIEW_REQUIRED
输入,需在下单前进行审核。

Step 2: Run the Gate

步骤2:运行校验门

bash
python3 skills/pre-trade-discipline-gate/scripts/check_pre_trade_discipline.py \
  --answers-file state/manual-entry-checklist.json \
  --state-dir state/theses \
  --market-regime-decision reports/exposure_decision_latest.json \
  --circuit-breaker-decision reports/circuit_breaker_decision_latest.json \
  --output-dir reports/pre-trade-discipline \
  --journal-dir state/journal/pre-trade-discipline
Set
--as-of
for deterministic testing or backfills:
bash
python3 skills/pre-trade-discipline-gate/scripts/check_pre_trade_discipline.py \
  --answers-file state/manual-entry-checklist.json \
  --as-of 2026-07-03T12:00:00-04:00
bash
python3 skills/pre-trade-discipline-gate/scripts/check_pre_trade_discipline.py \
  --answers-file state/manual-entry-checklist.json \
  --state-dir state/theses \
  --market-regime-decision reports/exposure_decision_latest.json \
  --circuit-breaker-decision reports/circuit_breaker_decision_latest.json \
  --output-dir reports/pre-trade-discipline \
  --journal-dir state/journal/pre-trade-discipline
设置
--as-of
参数用于确定性测试或回溯填充:
bash
python3 skills/pre-trade-discipline-gate/scripts/check_pre_trade_discipline.py \
  --answers-file state/manual-entry-checklist.json \
  --as-of 2026-07-03T12:00:00-04:00

Step 3: Interpret the Decision

步骤3:解读决策

DecisionMeaning
GO
All actionable manual-order candidates passed the checklist and upstream gates
REVIEW_REQUIRED
Inputs are missing, unknown, or journaling failed; do not place orders until reviewed
NO_GO
At least one actionable candidate violated a discipline rule
NO_ACTIONABLE_ORDERS
The file contains no actionable manual orders; nothing should be placed
By default the CLI exits
0
for every valid decision and exits
1
only for input or runtime errors. Use
--fail-on-non-go
when a shell pipeline should return
2
for any non-
GO
decision.
决策结果含义
GO
所有可执行手动订单候选均通过检查清单和上游校验门
REVIEW_REQUIRED
输入缺失、未知或记录失败;下单前需先审核
NO_GO
至少一个可执行候选违反了纪律规则
NO_ACTIONABLE_ORDERS
文件中无任何可执行手动订单;无需下单
默认情况下,CLI对所有有效决策返回退出码
0
,仅在输入或运行时错误时返回退出码
1
。当Shell流水线需要对任何非
GO
决策返回退出码
2
时,使用
--fail-on-non-go
参数。

Rules

规则

The gate blocks an actionable candidate when:
  • The entry is not confirmed in the written plan
  • The stop is not predefined
  • The size is not confirmed within plan
  • Either risk-dollar field is missing or is not a finite, non-negative number (
    REVIEW_REQUIRED
    )
  • actual_risk_dollars
    exceeds
    planned_risk_dollars
  • trader-memory-core has a losing exit or partial loss inside the revenge window
  • exposure-coach recommendation is
    REDUCE_ONLY
    or
    CASH_PRIORITY
  • drawdown-circuit-breaker recommendation is
    COOLDOWN
    ,
    HALTED
    , or
    TRADING_HALTED
Missing or unreadable market-regime or circuit-breaker artifacts produce
REVIEW_REQUIRED
for actionable orders. If no actionable order exists, the result remains
NO_ACTIONABLE_ORDERS
.
当出现以下情况时,校验门将阻止可执行候选订单:
  • 入场未在书面计划中确认
  • 止损未预先定义
  • 仓位规模未在计划范围内确认
  • 任一风险美元字段缺失或不是有限的非负数(标记为
    REVIEW_REQUIRED
  • actual_risk_dollars
    超过
    planned_risk_dollars
  • trader-memory-core显示在报复窗口内存在亏损离场或部分亏损
  • exposure-coach的建议为
    REDUCE_ONLY
    CASH_PRIORITY
  • drawdown-circuit-breaker的建议为
    COOLDOWN
    HALTED
    TRADING_HALTED
市场机制或熔断机制工件缺失或无法读取时,可执行订单会被标记为
REVIEW_REQUIRED
。如果没有可执行订单,结果仍为
NO_ACTIONABLE_ORDERS

Outputs

输出

The script writes:
  • pre_trade_discipline_decision_YYYY-MM-DD_HHMMSS.json
  • A matching markdown report unless
    --json-only
    is set
  • A JSONL journal row under
    state/journal/pre-trade-discipline/
    when
    --journal-dir
    is provided
Each candidate result includes a
checklist_answers
object with the written-plan, stop, size, risk-dollar, and notes answers used for the decision, so later reviews can audit what was answered at order time. Invalid risk-dollar values are stored as JSON
null
, while valid values retain their original representation.
If a candidate includes
thesis_id
and
--state-dir
is provided, the JSON report is linked into the thesis
linked_reports
list using trader-memory-core
link_report
. The skill does not call
mark_reviewed
and does not change monitoring review dates.
脚本会生成以下内容:
  • pre_trade_discipline_decision_YYYY-MM-DD_HHMMSS.json
  • 对应的Markdown报告(除非设置了
    --json-only
    参数)
  • 当提供
    --journal-dir
    参数时,在
    state/journal/pre-trade-discipline/
    下生成JSONL格式的记录行
每个候选订单结果包含
checklist_answers
对象,其中包含用于决策的书面计划、止损、仓位规模、风险美元和备注答案,以便后续审核可追溯下单时的回答内容。无效的风险美元值会存储为JSON
null
,有效值则保留其原始格式。
如果候选订单包含
thesis_id
且提供了
--state-dir
参数,JSON报告会通过trader-memory-core的
link_report
方法关联到交易论点的
linked_reports
列表中。该Skill不会调用
mark_reviewed
方法,也不会更改监控审核日期。

Resources

资源

  • scripts/check_pre_trade_discipline.py
    - Main CLI and rule engine
  • references/discipline_gate_framework.md
    - Rule definitions and integration notes
  • skills/trader-memory-core/schemas/thesis.schema.json
    - Thesis state schema
  • scripts/check_pre_trade_discipline.py
    - 主CLI和规则引擎
  • references/discipline_gate_framework.md
    - 规则定义和集成说明
  • skills/trader-memory-core/schemas/thesis.schema.json
    - 交易论点状态 schema

Key Principles

核心原则

  1. Manual execution only - The output is a pre-broker checklist gate, not an order router.
  2. Written plan first - No written entry plan, stop, or size confirmation means no manual entry.
  3. Producer-compatible state reading - Revenge-risk detection follows trader-memory-core timestamp and outcome behavior.
  4. Journal without review side effects - The gate links reports to theses without advancing review schedules.
  1. 仅支持手动执行 - 输出是经纪商下单前的检查清单校验门,而非订单路由工具。
  2. 书面计划优先 - 若无书面入场计划、止损或仓位规模确认,则不允许手动下单。
  3. 兼容生产者状态读取 - 报复性风险检测遵循trader-memory-core的时间戳和结果行为。
  4. 记录但不产生审核副作用 - 校验门将报告关联到交易论点,但不会推进审核日程。