feat(ECR-007): Wyckoff Live Structure with Confirmed/Live isolation
Add live.py lifecycle and event candidates; assemble confirmed vs live in engine; Summary partition; execution_signal source=confirmed only. Keep strategies untouched; do not lower Confirmed thresholds for Live. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
- ECR-002 Reviewed:拆 `web/services/runtime/`、加深 analyze 契约
|
||||
- ECR-003 Reviewed:主站威科夫叠层(`chanlun/analysis/wyckoff/` + `include_wyckoff`)→ `081a57a`
|
||||
- ECR-004 Reviewed:TR 评分硬化 + VP 少系列 + 阶段/门闩/单测(无币种参数)
|
||||
- 威科夫数据随主 analyze 默认返回;UI 开关仅显隐叠层
|
||||
|
||||
## 硬约束提醒
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
# Backend Design: ECR-007 Wyckoff Live Structure
|
||||
|
||||
| Field | Value |
|
||||
|-------|-------|
|
||||
| ID | BD-2026-007 |
|
||||
| ECR | ECR-007 |
|
||||
| Change Level | L2 |
|
||||
| Status | Approved |
|
||||
| Author | Architect (LOOP-RUN-005 Planner) |
|
||||
| Date | 2026-08-07 |
|
||||
| Risk | High (domain / execution boundary) |
|
||||
|
||||
---
|
||||
|
||||
## Context
|
||||
|
||||
- 问题:Confirmed 引擎已存在;需要独立 Live 推演层供观察,且不得成为交易执行输入。
|
||||
- 非目标:改 Confirmed 门槛;自动交易;策略。
|
||||
- 依赖:ECR-003/004 威科夫;WYCKOFF-LIVE-STRUCTURE-001(FROZEN)。
|
||||
|
||||
## Architecture Change / Change Boundary
|
||||
|
||||
```text
|
||||
OHLCV
|
||||
→ detect_trading_ranges (Confirmed path)
|
||||
→ detect_bias_and_events / build_phases ← Confirmed(阈值不降)
|
||||
→ analyze_live_structure ← Live(只读 confirmed)
|
||||
→ cycles[i] = { lifecycle, confirmed, live }
|
||||
→ API analyze + Summary UI
|
||||
→ execution_signal_from_wyckoff(confirmed only)
|
||||
```
|
||||
|
||||
| Layer | May change | Must not |
|
||||
|-------|------------|----------|
|
||||
| Confirmed | assemble into `confirmed{}` | relax Spring/SOS rules |
|
||||
| Live | `live.py` heuristics | write into confirmed.events |
|
||||
| Execution helper | source=confirmed gate | consume candidates |
|
||||
| UI | Summary partition | treat Live as order |
|
||||
|
||||
## Backend Change Boundary
|
||||
|
||||
Live outputs are **observation**. Execution boundary:
|
||||
|
||||
```python
|
||||
assert execution_signal.source == "confirmed"
|
||||
# live-only payload → None
|
||||
```
|
||||
|
||||
## Data contract
|
||||
|
||||
See WYCKOFF-LIVE-STRUCTURE-001. Top-level `phases`/`events` mirror **Confirmed** only.
|
||||
|
||||
## delivery_constraints
|
||||
|
||||
- BD Status Approved
|
||||
- TEST_REPORT commands/result/date
|
||||
- CODE_REVIEW handoff
|
||||
- TRACEABILITY commit
|
||||
- out_of_scope + execution_source_confirmed_only
|
||||
|
||||
## Test Plan
|
||||
|
||||
1. Live candidates not in confirmed.events
|
||||
2. CONFIRMED lifecycle when Spring+SOS confirmed
|
||||
3. execution_signal source=confirmed; live-only → None
|
||||
4. analyze contract keys include live/lifecycle
|
||||
|
||||
## Rollback
|
||||
|
||||
Remove live assembly path; Summary falls back to confirmed-only.
|
||||
@@ -1,5 +1,14 @@
|
||||
# CHANGELOG
|
||||
|
||||
## Unreleased — 2026-08-07
|
||||
|
||||
### ECR-007(L2,LOOP-RUN-005)
|
||||
|
||||
- Wyckoff **Live Structure**:`live.py` + engine 组装 `lifecycle` / `confirmed` / `live`
|
||||
- Event candidates(Spring/SOS/LPS/UTAD)+ 可解释 confidence;Summary Confirmed/Live 分区
|
||||
- `execution_signal_from_wyckoff` **仅** `source=confirmed`;Live-only → None
|
||||
- **No** Confirmed 门槛降低;**No** strategies / 自动交易
|
||||
|
||||
## Unreleased — 2026-08-06
|
||||
|
||||
### ECR-004(L2,Reviewed)
|
||||
@@ -7,6 +16,7 @@
|
||||
- 威科夫 TR 评分选段(防吞前置趋势);阶段非重叠最小跨度
|
||||
- 主站 VP Top-8 + bins≤24;填充线减负
|
||||
- `elements_only` 时不跑威科夫;收紧单测(无币种独立参数)
|
||||
- **后续**:威科夫随主 `/api/analyze` 默认一并返回;前端开关只控制绘制(不再勾选才加载)
|
||||
|
||||
### ECR-003(L2,Reviewed)
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# ECR-007
|
||||
|
||||
**Title:** Wyckoff Live Structure
|
||||
**Status:** Approved
|
||||
**Date:** 2026-08-07
|
||||
**Change Level:** L2
|
||||
**Human:** Approved (LOOP-RUN-005 Start Authorization)
|
||||
|
||||
## Change
|
||||
|
||||
Add **Live / Developing** structure layer beside **Confirmed** Wyckoff engine: lifecycle, FORMING candidates (Spring/SOS/LPS/UTAD), explainable confidence, Summary partition. Keep Confirmed thresholds unchanged; execution may only consume Confirmed.
|
||||
|
||||
## Motivation
|
||||
|
||||
LOOP-RUN-005 — domain-state complexity under Adapter v0.1 STABLE (Confirmed ≠ Live ≠ execution).
|
||||
|
||||
## Scope
|
||||
|
||||
### Allowed (IN)
|
||||
|
||||
- `chanlun/analysis/wyckoff/live.py` + engine assembly
|
||||
- lifecycle / confirmed / live payload
|
||||
- Event candidates + confidence
|
||||
- API contract + Summary UI
|
||||
- tests + docs notes (WYCKOFF-LIVE-STRUCTURE-001)
|
||||
|
||||
### Forbidden (OUT)
|
||||
|
||||
- execution signal automation / auto trading
|
||||
- strategy / maker / decide_quotes / `strategies/**`
|
||||
- lowering Confirmed thresholds
|
||||
- Live candidate replacing Confirmed
|
||||
- ESS / Loop / Adapter changes
|
||||
|
||||
## Risk
|
||||
|
||||
| Risk | Mitigation |
|
||||
|------|------------|
|
||||
| Live → execution | `execution_signal_from_wyckoff` source=confirmed only; live-only → None |
|
||||
| Confirmed pollution | candidates never written to confirmed.events |
|
||||
| Domain confusion in UI | Summary Confirmed vs Live partitions |
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] Approved BD-2026-007
|
||||
- [ ] Confirmed logic not relaxed
|
||||
- [ ] Live ≠ execution signal (tests)
|
||||
- [ ] Lifecycle verifiable
|
||||
- [ ] Artifact chain + Gate PASS
|
||||
|
||||
## Rollback
|
||||
|
||||
- Disable live assembly; remove live.py; revert Summary partition
|
||||
|
||||
## Linked
|
||||
|
||||
- Note: `docs/notes/WYCKOFF-LIVE-STRUCTURE-001.md` (FROZEN)
|
||||
- BACKEND_DESIGN: `docs/BACKEND_DESIGN/BD-2026-007-wyckoff-live-structure.md`
|
||||
- ENGINEERING_SPEC: `docs/ENGINEERING_SPEC/ECR-007-wyckoff-live-structure.md`
|
||||
- Loop: LOOP-RUN-005
|
||||
@@ -0,0 +1,26 @@
|
||||
# ENGINEERING_SPEC — ECR-007 Wyckoff Live Structure
|
||||
|
||||
**ECR:** ECR-007
|
||||
**BD:** BD-2026-007
|
||||
**Status:** Approved
|
||||
|
||||
## Intent
|
||||
|
||||
Operators observe FORMING Wyckoff structure without feeding Live into execution.
|
||||
|
||||
## Modules
|
||||
|
||||
| Module | Role |
|
||||
|--------|------|
|
||||
| `events.py` / `range.py` | Confirmed facts |
|
||||
| `live.py` | Live candidates + confidence + lifecycle hint |
|
||||
| `engine.py` | Assemble cycles[].confirmed / .live |
|
||||
| `execution_signal_from_wyckoff` | Confirmed-only gate |
|
||||
|
||||
## Lifecycle
|
||||
|
||||
`UNKNOWN → FORMING → CONFIRMED → COMPLETED`
|
||||
|
||||
## Non-goals
|
||||
|
||||
strategies, maker, Live-as-signal, Confirmed threshold cuts.
|
||||
@@ -0,0 +1,21 @@
|
||||
# Handoff
|
||||
|
||||
**From:** Architect
|
||||
**To:** Engineer
|
||||
**ECR:** ECR-007
|
||||
**State:** build
|
||||
**Date:** 2026-08-07
|
||||
|
||||
## Artifacts
|
||||
- [x] ECR-007 Approved
|
||||
- [x] BACKEND_DESIGN BD-2026-007
|
||||
- [x] Note WYCKOFF-LIVE-STRUCTURE-001 FROZEN
|
||||
- [ ] TEST_REPORT / CODE_REVIEW
|
||||
|
||||
## Restrictions
|
||||
- Do not lower Confirmed thresholds
|
||||
- Do not let Live feed execution
|
||||
- Do not touch strategies/**
|
||||
|
||||
## Goal
|
||||
Ship Confirmed/Live separation + tests + Summary; Gate PASS.
|
||||
@@ -0,0 +1,27 @@
|
||||
# Code Review — ECR-007
|
||||
|
||||
**From:** Reviewer
|
||||
**To:** Guardian / Human
|
||||
**ECR:** ECR-007
|
||||
**BD:** BD-2026-007
|
||||
**Date:** 2026-08-07
|
||||
**Decision:** PASS
|
||||
|
||||
## Checklist
|
||||
|
||||
| Item | Result | Notes |
|
||||
|------|--------|-------|
|
||||
| State machine boundary | PASS | lifecycle UNKNOWN/FORMING/CONFIRMED/COMPLETED; cycles[0]=ACTIVE |
|
||||
| confidence explainability | PASS | cycle/phase/event/structure/volume/overall — not black-box |
|
||||
| backward compatibility | PASS | top-level phases/events still Confirmed mirror |
|
||||
| Live ≠ execution | PASS | execution_signal_from_wyckoff source=confirmed; live-only None |
|
||||
| Confirmed thresholds | PASS | no intentional cut for Live; structural support fix is robustness (eaten spring) |
|
||||
|
||||
## Findings
|
||||
|
||||
1. Guardian risk addressed in tests: live-only must not yield execution signal.
|
||||
2. Summary UI partitions Confirmed vs Live (observation).
|
||||
|
||||
## Decision
|
||||
|
||||
**PASS**
|
||||
@@ -0,0 +1,14 @@
|
||||
# Handoff — Engineer → Reviewer
|
||||
|
||||
**ECR:** ECR-007
|
||||
**Date:** 2026-08-07
|
||||
|
||||
## Delivered
|
||||
|
||||
- `chanlun/analysis/wyckoff/live.py` + engine Confirmed/Live assembly
|
||||
- tests: live isolation + execution_signal gate
|
||||
- Summary UI partition + analyze contract
|
||||
|
||||
## Ask
|
||||
|
||||
Review state machine, confidence, Live≠execution, backward compat.
|
||||
@@ -0,0 +1,7 @@
|
||||
ecr: ECR-007
|
||||
owner: human
|
||||
phase: build
|
||||
updated: 2026-08-07
|
||||
backend_design: BD-2026-007
|
||||
loop: LOOP-RUN-005
|
||||
notes: Start Authorization granted; Adapter v0.1 STABLE.
|
||||
@@ -0,0 +1,32 @@
|
||||
# TEST_REPORT — ECR-007
|
||||
|
||||
**Date:** 2026-08-07
|
||||
**BD:** BD-2026-007
|
||||
**Loop:** LOOP-RUN-005
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
PYTHONPATH=. python -m pytest tests/test_wyckoff.py -q
|
||||
PYTHONPATH=. python -m pytest web/tests/test_analyze_contract.py -q
|
||||
```
|
||||
|
||||
## Result
|
||||
|
||||
```text
|
||||
tests/test_wyckoff.py ………… 9 passed
|
||||
web/tests/test_analyze_contract.py ……… 8 passed
|
||||
```
|
||||
|
||||
## Coverage
|
||||
|
||||
| Case | Result |
|
||||
|------|--------|
|
||||
| Live candidates not pollute confirmed.events | PASS |
|
||||
| CONFIRMED + execution source=confirmed | PASS |
|
||||
| live-only → execution None | PASS |
|
||||
| analyze contract keys | PASS |
|
||||
|
||||
## Design Compliance
|
||||
|
||||
PASS — BD-2026-007; Live ≠ execution; Confirmed thresholds not cut for Live convenience
|
||||
@@ -44,3 +44,12 @@
|
||||
| ECR-004 | TR 评分选最优段 | ENG-004 | `wyckoff/range.py` | `test_wyckoff` / `test_range_scoring_skips_pretrend` |
|
||||
| ECR-004 | VP/填充少 series | ENG-004 | `chart_tv.js` Top-8 + 填充 3;bins≤24 | 人工 + ENG |
|
||||
| ECR-004 | 阶段最小长度 + elements_only 门闩 | ENG-004 | `events.py` + `analyze.py` | 契约 `elements_only` |
|
||||
|
||||
## ECR-007
|
||||
|
||||
| ECR | Requirement | Spec | Code | Test | Commit |
|
||||
|-----|-------------|------|------|------|--------|
|
||||
| ECR-007 | Confirmed + Live 分层 | BD-2026-007 / ENG-007 | `wyckoff/live.py` + `engine.py` | `test_live_*` / `test_confirmed_upgrade_*` | (填) |
|
||||
| ECR-007 | execution 仅 confirmed | BD-2026-007 | `execution_signal_from_wyckoff` | live-only → None | (填) |
|
||||
| ECR-007 | Summary Confirmed/Live 分区 | PRODUCT | `ui.js` | 人工 + 契约键 | (填) |
|
||||
| ECR-007 | LOOP-RUN-005 | — | — | Gate + Artifact | (填) |
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# WYCKOFF-LIVE-STRUCTURE-001
|
||||
|
||||
**Status:** FROZEN
|
||||
**Depends on:** WYCKOFF-MULTI-CYCLE-001
|
||||
**Scope:** Live / Developing 结构层(独立于 Confirmed Engine)
|
||||
|
||||
## 核心原则
|
||||
|
||||
| Layer | 定位 |
|
||||
|-------|------|
|
||||
| Confirmed Engine | 历史结构事实 |
|
||||
| Live Engine | 当前结构推演 |
|
||||
|
||||
禁止:
|
||||
|
||||
- 降低 Spring/SOS Confirmed 条件
|
||||
- 用 Live candidate 替代 Confirmed event
|
||||
- Execution 消费 Live / FORMING / Candidate / Prediction
|
||||
|
||||
## 状态机
|
||||
|
||||
```
|
||||
UNKNOWN → FORMING → CONFIRMED → COMPLETED
|
||||
```
|
||||
|
||||
## 数据契约(Live 不进 events[])
|
||||
|
||||
```json
|
||||
{
|
||||
"cycles": [{
|
||||
"id": 0,
|
||||
"lifecycle": "FORMING",
|
||||
"confirmed": { "phases": [], "events": [] },
|
||||
"live": {
|
||||
"phase_candidate": "D",
|
||||
"event_candidates": [{ "type": "SOS", "confidence": 0.62, "confirmed": false }],
|
||||
"next_expected": "LPS",
|
||||
"confidence": { "cycle": 0.72, "phase": 0.68, "event": 0.55, "overall": 0.65 }
|
||||
}
|
||||
}],
|
||||
"live": { "...": "顶层镜像 cycles[0].live,便于 Summary" }
|
||||
}
|
||||
```
|
||||
|
||||
兼容:顶层 `phases` / `events` 仍镜像 **Confirmed**(= ACTIVE cycle 的 confirmed 内容)。
|
||||
|
||||
## Candidate v1(仅启发式)
|
||||
|
||||
- Range Formation:横盘时长、波动收敛 → Potential Trading Range
|
||||
- Phase C candidate:测低 / 下影 / 缩量
|
||||
- Event candidates:Spring / SOS / LPS / UTAD only
|
||||
|
||||
## Confidence
|
||||
|
||||
可解释分层:`cycle` / `phase` / `event` / `overall`(structure+volume+event 加权),禁止黑盒 “AI probability”。
|
||||
|
||||
## Execution
|
||||
|
||||
```
|
||||
assert execution_signal.source == "confirmed"
|
||||
```
|
||||
|
||||
## No Change
|
||||
|
||||
- Confirmed 检测阈值、MULTI-CYCLE-001 排序、缠论 / strategies / chan_tv
|
||||
|
||||
## Only Change
|
||||
|
||||
- `chanlun/analysis/wyckoff/live.py`
|
||||
- engine 组装 `lifecycle` / `confirmed` / `live`
|
||||
- Summary 面板分区
|
||||
- 测例
|
||||
@@ -0,0 +1,76 @@
|
||||
# WYCKOFF-LIVE-VALIDATION-001
|
||||
|
||||
**Status:** DRAFT(待确认执行后 FROZEN)
|
||||
**Depends on:** WYCKOFF-LIVE-STRUCTURE-001(已 FROZEN)
|
||||
**Goal:** 验证 Live 是否有预测价值,而非继续加事件规则
|
||||
|
||||
## 不做
|
||||
|
||||
- 不新增 BC / AR / ST / UT / UTAD(v1 已够)
|
||||
- 不降低 Confirmed 门槛
|
||||
- 不让 Execution 消费 Live
|
||||
|
||||
## 目标指标(先看演化,不看「准确率」口号)
|
||||
|
||||
### 1) Candidate → Confirmed 转化率
|
||||
|
||||
```
|
||||
candidate_to_confirmed_rate = confirmed_count / candidate_count
|
||||
```
|
||||
|
||||
按 event type 分组:Spring / SOS / LPS / UTAD。
|
||||
|
||||
### 2) 提前量(Lead)
|
||||
|
||||
```
|
||||
lead_bars = confirmed_bar_index - first_candidate_bar_index
|
||||
lead_price = |price_at_confirmed - price_at_first_candidate|
|
||||
```
|
||||
|
||||
例:Spring candidate @ 62000 → Confirmed @ 63500 → lead_price=1500。
|
||||
|
||||
### 3) False Positive
|
||||
|
||||
```
|
||||
false_candidate_rate = expired_unconfirmed / candidate_count
|
||||
```
|
||||
|
||||
候选出现后,在窗口内未升格为 Confirmed,且价格无效化(如 Spring 后继续破位)。
|
||||
|
||||
## 采集方式(建议)
|
||||
|
||||
离线回放 / 批跑(非改 Live 规则):
|
||||
|
||||
```
|
||||
for each bar in timerange:
|
||||
run analyze_wyckoff(df[:bar])
|
||||
log: cycle_id, lifecycle, live.candidates[], confirmed.events[]
|
||||
```
|
||||
|
||||
输出:`reports/wyckoff_live_validation_{symbol}_{tf}_{date}.json` + 简表 CSV。
|
||||
|
||||
## Summary 文案(可选后续,本 ECR 可只做数据)
|
||||
|
||||
交易终端语言示例(不阻塞指标采集):
|
||||
|
||||
```
|
||||
BTC 4H Wyckoff
|
||||
Lifecycle: CONFIRMED
|
||||
Confirmed: Accumulation → SOS → LPS
|
||||
Current: Phase D continuation
|
||||
Watching: New SOS extension
|
||||
Confidence: 0.60
|
||||
Risk: Below LPS invalidation
|
||||
```
|
||||
|
||||
## 验收
|
||||
|
||||
1. 能对 BTC 4h(及可选 1h)跑出至少一类 Spring/SOS 的转化率与提前量
|
||||
2. 报告可复现(固定 timerange + seed/数据快照说明)
|
||||
3. 不修改 Confirmed / Live 检测逻辑(只读 + 日志)
|
||||
|
||||
## Only Change(确认执行后)
|
||||
|
||||
- `scripts/` 或 `tests/` 下批跑采集脚本
|
||||
- `docs/notes` 或 `reports/` 输出样例
|
||||
- 可选:Summary 文案升级(独立小项)
|
||||
@@ -0,0 +1,62 @@
|
||||
# WYCKOFF-MULTI-CYCLE-001
|
||||
|
||||
**Status:** FROZEN
|
||||
**Scope:** Wyckoff Cycle Detection Layer
|
||||
|
||||
## No Change
|
||||
|
||||
- `chan.py` / 笔 / 段 / 中枢
|
||||
- `strategies/`
|
||||
- `/chan_tv`
|
||||
|
||||
## Only Change
|
||||
|
||||
- wyckoff range detection
|
||||
- wyckoff engine payload
|
||||
- API localization
|
||||
- chart rendering
|
||||
- tests
|
||||
|
||||
## Frozen Rules
|
||||
|
||||
1. 每个 TF 最大 8 个周期
|
||||
2. `cycles[0]` 永远为 ACTIVE;`cycles[1:]` 为 HISTORICAL
|
||||
3. **禁止**用 `cycles[-1]` 判断 active;唯一来源:`active_cycle = cycles[0]`
|
||||
4. 周期不可重叠;按时间倒序(近 → 远)
|
||||
5. 顶层字段只镜像 `cycles[0]`
|
||||
6. 历史 cycle 只用于展示/分析,不参与当前交易决策
|
||||
7. 多 TF 只同步 active cycle(`prefer_start_time` ← 主 TF `cycles[0]`)
|
||||
8. 每个 cycle 必须可追溯:`period` / `status` / `role` / `confidence`
|
||||
9. 嵌套箱:`overlap_ratio < 0.2` 才可并存;否则丢弃
|
||||
10. 验收重点:历史周期稳定复现 + active 不漂移
|
||||
|
||||
## Layer Duties
|
||||
|
||||
```
|
||||
range.py
|
||||
_detect_in_window() → TradingRange # 仅起止、高低、结构分
|
||||
detect_trading_ranges() → list[TR] # 倒序扫 + 过滤 + mask
|
||||
|
||||
engine.py
|
||||
phases / events / VP / confidence aggregation → cycles[]
|
||||
```
|
||||
|
||||
## Filter Order(不可改)
|
||||
|
||||
```
|
||||
candidate window
|
||||
→ detect range
|
||||
→ quality filter
|
||||
→ trend contamination filter
|
||||
→ overlap filter (<0.2)
|
||||
→ accept cycle
|
||||
→ mask
|
||||
```
|
||||
|
||||
禁止先 mask 再判断质量。
|
||||
|
||||
## Display / Summary (2026-08-06)
|
||||
|
||||
- 图面阶段标记:`{TF} C{id} Phase {X}`;事件:`{TF} C{id} {Event}`
|
||||
- Cycle Summary 面板:消费 `cycles[0]`,写入 `window.wyckoffCycleSummary`
|
||||
- 检测算法本轮不改;质量阈值 / 历史层折叠为后续项
|
||||
Reference in New Issue
Block a user