Skip to content

Commit cd55093

Browse files
committed
Merge branch 'feature/research-fib' of https://github.com/JohnCCarter/Fibonacci-Research-Experiment into feature/research-fib
2 parents d1ddfc3 + dde39a1 commit cd55093

45 files changed

Lines changed: 5599 additions & 310 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

data/labels/INDEX.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
# Label index
1+
# Label index
22

3-
Oversikt over golden set (`data/labels/`).
3+
Översikt över golden set (`data/labels/`). Counts reflect **base** `fib_*.json` on disk
4+
(excluding regenerable `*_events.json` / `*_interactions.csv` sidecars).
45

5-
**Status (2026-06-10):** BTC monthly-first protocol — active human fib facit below.
6-
Counts reflect base `fib_*.json` on disk. Prior mixed-symbol facit **and** the
7-
pre-reset 1w/1d/4h labels are archived under
6+
**Status (2026-06-15):** BTC monthly-first protocol — active human fib facit below.
7+
Authority for phase status is [handoff.md](../../docs/research_wiki/handoff.md); this file
8+
indexes on-disk label counts. Prior mixed-symbol facit **and** the pre-reset 1w/1d/4h
9+
labels are archived under
810
`archive/research_superseded/2026-06-08_pre_btc_monthly_reset/data/` and
911
`archive/research_superseded/2026-06-09_pre_log_fib_profile_reset/`**not** current.
1012

1113
## Active human fib (BTC/USD)
1214

13-
| symbol | timeframe | count | notes |
14-
|--------|-----------|------:|-------|
15-
| BTC/USD | 1M | 9 | monthly anchors (facit, log scale)review in progress |
16-
| BTC/USD | 1w | 0 | pending re-draw (blocked on 1M sign-off) |
17-
| BTC/USD | 1d | 0 | pending re-draw |
18-
| BTC/USD | 4h | 0 | pending re-draw |
15+
| symbol | timeframe | count | up/down | notes |
16+
|--------|-----------|------:|---------|-------|
17+
| BTC/USD | 1M | 9 | 5 / 4 | monthly anchors (log scale); 1D+4H reaction review approved |
18+
| BTC/USD | 1w | 21 | 13 / 8 | source-facit complete |
19+
| BTC/USD | 1d | 67 | 33 / 34 | source-facit complete |
20+
| BTC/USD | 4h | 365 | 168 / 197 | source-facit complete; 366 drawn, 1 superseded (20250506 dedup) |
1921

20-
1w/1d/4h directories are absent on disk; prior counts (pre-reset) are archived,
21-
not current evidence. See [handoff.md](../../docs/research_wiki/handoff.md).
22+
All BTC/USD ladders use log scale + `tradingview_log_chamoun` (no 0.236), human/manual
23+
origin. The 4H `20250506` dedup (08:00 fib superseded in favour of 12:00 fib) is recorded
24+
in [reviews/btc-4h-fib-20250506-dedup-20260615.md](../../docs/research_wiki/reviews/btc-4h-fib-20250506-dedup-20260615.md)
25+
and the [source-quality ledger](../../docs/research_wiki/reviews/ledgers/btc-4h-source-quality-ledger.csv).
2226

23-
Base files: `human_fib/bitfinex/BTC-USD/{timeframe}/fib_*.json`
27+
Base files: `human_fib/bitfinex/BTC-USD/{timeframe}/fib_*.json`
2428
Regenerable sidecars (not versioned): `*_events.json`, `*_interactions.csv`
2529

2630
Swing golden set (`bitfinex/BTC-USD/{timeframe}.json`): none yet.

data/labels/human_fib/bitfinex/BTC-USD/4h/fib_BTC-USD_4h_20171228T200000.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"levels_profile": "tradingview_log_chamoun",
1010
"human_highlights": [],
1111
"anchor_a": {
12-
"time": "2017-12-28T20:00:00+00:00",
13-
"price": 13611.0
12+
"time": "2017-12-28T08:00:00+00:00",
13+
"price": 13145.0
1414
},
1515
"anchor_b": {
1616
"time": "2017-12-29T00:00:00+00:00",
@@ -25,23 +25,23 @@
2525
},
2626
{
2727
"ratio": 0.382,
28-
"price": 14417.6561003
28+
"price": 14227.06169429
2929
},
3030
{
3131
"ratio": 0.5,
32-
"price": 14260.02594668
32+
"price": 14013.78963735
3333
},
3434
{
3535
"ratio": 0.618,
36-
"price": 14104.11918452
36+
"price": 13803.7146545
3737
},
3838
{
3939
"ratio": 0.786,
40-
"price": 13885.08665832
40+
"price": 13510.046753
4141
},
4242
{
4343
"ratio": 1.0,
44-
"price": 13611.0
44+
"price": 13145.0
4545
}
4646
]
4747
}

data/labels/human_fib/bitfinex/BTC-USD/4h/fib_BTC-USD_4h_20250506T080000.json

Lines changed: 0 additions & 47 deletions
This file was deleted.

docs/labeling/HUMAN_FIB_ANNOTATION.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,40 @@ uv run python -m fibengine.labeling.human_fib \
4545

4646
---
4747

48+
## Single-fib declutter edit-mode (2026-06-15)
49+
50+
För säker granskning/korrigering av **en** sparad human fib utan plottriga HTF-overlays:
51+
52+
```bash
53+
uv run --no-sync python -m fibengine.labeling.tool \
54+
--symbol BTC/USD --timeframe 4h \
55+
--edit-fib-id fib_BTC-USD_4h_20171228T200000 \
56+
--config config/settings.expansion.yaml
57+
```
58+
59+
`--edit-fib-id` laddar exakt den fiben, döljer HTF-overlays, auto-fittar fönstret till
60+
A→B-spannet och förladdar ankarna som aktiva high/low-picks. **Read-only vid load**
61+
inget sparas förrän du trycker `w`. Failar tydligt vid okänd/tvetydig fib-id eller
62+
fel symbol/timeframe. Standardläget (utan flaggan) är oförändrat.
63+
64+
## Ankar-konvention (observerad review-praxis, 2026-06-15)
65+
66+
Inte en absolut global regel — en **observerad current review-konvention** från BTC/USD
67+
4H-granskningen (Tier 2). Dokumenterad så att wick/body-frågor hanteras konsekvent:
68+
69+
- Vissa 4H crash-/impuls-ben ankras vid en **body/close-liknande nivå** snarare än den
70+
exakta **wick-extremen**. Exempel: Jan 2021-paret (`20210110T080000` /
71+
`20210110T200000`) delar `anchor_b` vid body/close (~30 635) i stället för wick-lowen.
72+
- Detta ska **inte** automatiskt klassas som fel — wick-vs-body är en bedömningsfråga.
73+
- En wick/body-avvikelse kan bli **watchlist** eller **correction-candidate** i
74+
review-ledgern, **inte** auto-fail.
75+
- Ankaret bedöms mot det **strukturella benet och den lokala swingen**, inte enbart mot
76+
den extrema wicken.
77+
78+
Spårning: verdicts i [review-ledgern](../research_wiki/reviews/ledgers/README.md);
79+
near-duplicate/overlap-kandidater via `research/overlap_detector.py`
80+
([rapport](../research_wiki/reviews/btc-4h-overlap-candidates-20260615.md)).
81+
4882
## Datamodell
4983

5084
```json

docs/research_wiki/handoff.md

Lines changed: 78 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,51 @@ append-only trail lives in [log.md](log.md).
1515
| 1 | **1M** | **Complete** — 9× source fibs, 1D + 4H reaction review approved (2026-06-11) |
1616
| 2 | **1W** | **Complete** — 21× source fibs verified; combined map + per-fib 4H zoom (2026-06-11) |
1717
| 3 | **1D** | **Complete** — 67× source fibs + 4H reaction-review (2026-06-12); 1816 events, 90-day window |
18-
| 4 | **4H** | **Complete**366× source fibs, 2017-01-05 → 2026-06-05 (2026-06-12) |
18+
| 4 | **4H** | **Complete**365 active source fibs (366 drawn; 1 superseded 20250506 dedup) |
1919
| 5 | 1H | Deferred — 1h cache not fetched yet |
2020

2121
**ETH/USD:** blocked until BTC protocol approved.
2222

2323
## Recent Changes
2424

25+
- **2026-06-15 Structural chart-contract snapshots (#F)**`research/render_summary.py`
26+
(stdlib): stable text summaries of map/zoom/gallery renders + golden JSON under
27+
`tests/research/snapshots/`. Automatic structural regression; no PNG baselines/deps.
28+
- **2026-06-15 20171228 source fib corrected** — preview-first flow: anchor_a moved
29+
2017-12-28T20:00 @ 13611 → 2017-12-28T08:00 @ 13145 (candidate_1). Only anchor_a + levels
30+
changed; anchor_b/fib_id unchanged; guard PASS; ledger candidate → corrected. Closes the
31+
declutter→correction→ledger track. [Report](reviews/btc-4h-fib-20171228-correction-20260615.md).
32+
- **2026-06-15 Single-fib declutter edit-mode**`labeling/tool.py --edit-fib-id` opens
33+
one saved human fib, hides HTF overlays, auto-fits window, preloads anchors (read-only;
34+
fail-closed `human_fib.find_annotation`). Default unchanged. 10 tests.
35+
- **2026-06-15 Overlap/dedup detector + anchor convention**`research/overlap_detector.py`
36+
(stdlib, report-only): boxes fibs in (time, log-price), flags near-duplicate/overlap
37+
candidates (box IoU + shared-anchor); never edits labels. Real run: 22 candidates (all
38+
shared anchor_b). Body/close-vs-wick convention noted in `HUMAN_FIB_ANNOTATION.md`.
39+
Issue #32 top-ROI #3. [Report](reviews/btc-4h-overlap-candidates-20260615.md).
40+
- **2026-06-15 Source-quality review ledger**`research/review_ledger.py` (stdlib): flat
41+
CSV making verdicts machine-trackable (controlled vocab + deterministic `source_hash`).
42+
First ledger = 4H Tier 2 (8 rows). Issue #32 top-ROI #2.
43+
- **2026-06-15 Static HTML artifact gallery**`research/artifact_gallery.py` (stdlib-only):
44+
scans a review PNG dir → self-contained `index.html` (relative links, clean+levels paired,
45+
auto-detects map/zoom layouts). Standalone; markdown index untouched; output gitignored.
46+
Issue #32 top-ROI #1. `python -m fibengine.research.artifact_gallery --root <dir>`.
47+
- **2026-06-15 4H Tier 2 first manual sample-pass + first correction-candidate** — 8 fibs
48+
inspected (4 per scope). Zoom resolves Tier 1 readability. **1 correction-candidate:**
49+
`20171228T200000` — visual review found a better anchor_a candle adjacent to leg A →
50+
suspicious; **deferred to a future correction-pass** (GUI too cluttered for safe manual
51+
edit; needs isolated single-fib view or exact target candle timestamp). No label changed.
52+
Watchlist: body/close vs wick convention (undocumented).
53+
Full review: [`reviews/btc-4h-tier2-sample-review-20260615.md`](reviews/btc-4h-tier2-sample-review-20260615.md).
54+
- **2026-06-15 4H Tier 1 map review complete** — all 11 annual groups inspected.
55+
9/11 map-OK. Two groups need Tier 2: **2017_h2** (103 fibs, Sep–Dec 2017 parabola —
56+
full Tier 2) and **2021** (partial — Dec 2020 → Mar 2021 cluster only, anchor_a
57+
in [2021-01-01, 2021-04-01), ~37 fibs). Threshold rule confirmed: local density per
58+
zone, not total fib count. Y-axis log confirmed (line 246 `monthly_fib_map.py`).
59+
Full review: [`reviews/btc-4h-tier1-map-review-20260615.md`](reviews/btc-4h-tier1-map-review-20260615.md).
2560
- **2026-06-12 4H visual confirmation Tier 1 built**`research/fourh_source_fib_map.py`
26-
renders **annual combined 4H source-fib maps** (fibs grouped by `anchor_a` year; dense
27-
years >60 fibs split into calendar half-years). Reuses `monthly_fib_map` primitives
28-
unchanged; no snap (source TF == chart TF == 4h); each group windowed by its fib span.
29-
Real run (facit + expansion cache): **366/366 fibs drawn, 0 skipped, 11 groups**
30-
2017=13h1/**103h2**, 2018=33, 2019=26, 2020=31, 2021=55, 2022=24, 2023=17, 2024=22,
31-
2025=34, 2026=8. Mid-density maps scan cleanly. **2017_h2 (~103 fibs, Sep–Dec parabola)
32-
exceeds map-reviewable density → flags 2017 for Tier 2 zoom.** 14 tests pass; ruff +
33-
repo-bounds + full suite green. Output gitignored under
34-
`experiments/review/fourh_source_fib_map/`. No reaction-review, no events, no auto-fib.
61+
renders annual combined 4H maps (366/366 drawn, 11 groups; dense 2017_h2 flagged for
62+
Tier 2). Reuses `monthly_fib_map` primitives; output gitignored. Full detail in log.md.
3563
- **2026-06-12 4H source-fib phase complete****366** manual BTC/USD 4H source fibs
3664
drawn and verified (timeframe `4h`, log scale, `tradingview_log_chamoun`, levels
3765
`[0, 0.382, 0.5, 0.618, 0.786, 1]`, no 0.236, endpoint mapping ratio 0.0=anchor_b /
@@ -64,37 +92,20 @@ append-only trail lives in [log.md](log.md).
6492
non-1W / non-log / wrong-profile / 0.236 / non-human fib. No auto-fib, no
6593
trading conclusions. Commits `4eb2f4b` (map + facit), `939de97` (zoom),
6694
`e379fae` (CI: format + bounds fix).
67-
- **2026-06-11 1M reaction-review cycle complete** — all 9 BTC/USD 1M source fibs
68-
reviewed through 1D + 4H. Review windows confirmed in `review_windows.yaml`.
69-
62 1D events, 127 4H events. Summary:
70-
[reviews/btc-1m-reaction-review-cycle-20260611.md](reviews/btc-1m-reaction-review-cycle-20260611.md).
71-
- **2026-06-10 Addendum 2 — retire golden-zone sampling** — issue #30: removed
72-
`primary_active_levels` / golden-zone review-sampling from configs, `core/config.py`,
73-
`human_review_pack`/`rows`/`constants`, and docs. All levels are event-capable and
74-
sampled equally (round-robin). Added `human_highlights` (presentation-only) to
75-
`HumanFibAnnotation`. Prior golden-zone 1M pack superseded by an unbiased regenerated pack.
76-
- **2026-06-09 log-scale + profile fix** — fib levels computed log-scale
77-
(`scale_mode: log`); profile `tradingview_log_chamoun` `[0, 0.382, 0.5, 0.618,
78-
0.786, 1]` (no 0.236). Charts render a log price axis (labeling tool + both review
79-
tools). (Golden-zone `primary_active_levels` sampling was later retired — see 2026-06-10.)
80-
Prior linear/0.236 labels, events, and review packs archived to
81-
`archive/research_superseded/2026-06-09_pre_log_fib_profile_reset/`.
82-
- **2026-06-09 1M re-label** — 9 monthly fibs re-drawn; `human_fib_events` +
83-
BTC-only review pack `human_fib_review_20260609T135548Z` (golden-zone biased).
84-
- **2026-06-09 events log-scale fix**`detect_level_events` / `human_fib_events`
85-
now compute level prices with the annotation's `scale_mode` (was always linear);
86-
events + pack regenerated so review level prices match the log facit.
87-
- **2026-06-08 reset** — prior experiments + mixed-symbol data archived to
88-
`archive/research_superseded/2026-06-08_pre_btc_monthly_reset/`.
95+
- **2026-06-08…11 (earlier milestones)** — 1M reaction-review cycle (9 fibs, 1D+4H),
96+
Addendum 2 golden-zone retirement (issue #30, added `human_highlights`), log-scale +
97+
profile fix, 1M re-label, events log-scale fix, and the BTC monthly-first reset. Full
98+
detail in [log.md](log.md) (append-only trail).
8999

90100
## Verification Snapshot
91101

92102
- `data/labels/human_fib/bitfinex/BTC-USD/1M/`**9** base `fib_*.json` (log scale).
93103
- `data/labels/human_fib/bitfinex/BTC-USD/1w/`**21** base `fib_*.json` (log scale).
94104
- `data/labels/human_fib/bitfinex/BTC-USD/1d/`**67** base `fib_*.json` (log scale);
95105
source-facit complete, verified 2026-06-11.
96-
- `data/labels/human_fib/bitfinex/BTC-USD/4h/`**366** base `fib_*.json` (log scale);
97-
source-facit complete, verified 2026-06-12. Coverage 2017-01-05 → 2026-06-05; up=169 / down=197.
106+
- `data/labels/human_fib/bitfinex/BTC-USD/4h/`**365** active base `fib_*.json` (log scale;
107+
366 drawn 2026-06-12, 1 superseded via 20250506 dedup 2026-06-15). Coverage 2017-01-05 →
108+
2026-06-05.
98109
- `experiments/review/weekly_source_fib_map/` and `…/weekly_source_fib_zoom/`
99110
generated charts (gitignored; regenerate via the two new CLIs).
100111
- `data/raw/bitfinex/BTC-USD/1M/limit_500.csv` — 115 bars (2016-12 .. 2026-06),
@@ -109,18 +120,32 @@ append-only trail lives in [log.md](log.md).
109120

110121
## Next Useful Action
111122

112-
1. **Human review of the Tier-1 4H maps** — open
113-
`experiments/review/fourh_source_fib_map/` (regenerate via the CLI below) and scan the
114-
per-year clean/levels PNGs to confirm 4H anchor pins sit on the correct structural
115-
swings. Tier 1 is **built** (2026-06-12): 366/366 drawn, 11 groups; most years scan
116-
cleanly. Regenerate:
117-
`uv run --no-sync python -m fibengine.research.fourh_source_fib_map --fib-dir data/labels/human_fib/bitfinex/BTC-USD/4h --config config/settings.expansion.yaml`
118-
2. **4H visual confirmation — Tier 2 (on-demand)**`fourh_source_fib_zoom.py` (per-fib
119-
windowed 4H charts). Tier 1 already flagged **2017_h2 (~103 fibs, Sep–Dec parabola)**
120-
as too dense to source-review as a map — start Tier 2 there if/when per-fib zoom is
121-
wanted. Design: [`reviews/btc-4h-visual-confirmation-design-20260612.md`](reviews/btc-4h-visual-confirmation-design-20260612.md).
122-
3. **1H source labeling** — deferred. 4H is the current lowest active timeframe. Fetch
123-
1H cache first (`data.fetch --timeframes 1h`). Separate decision before starting.
123+
**Milestone:** Issue #32 top-3 complete + pushed (gallery `8f1e7a8`, ledger `d6ab9ec`,
124+
overlap detector + anchor convention `84b42db`). local == origin, tree clean, source-fib
125+
JSON unchanged, no new deps, no artifacts committed.
126+
127+
**Next active track (recommended order):**
128+
129+
1. **Single-fib declutter edit-mode — DONE.** `labeling/tool.py --edit-fib-id`.
130+
2. **`fib_BTC-USD_4h_20171228T200000` correction — DONE.** anchor_a moved to 2017-12-28T08:00
131+
@ 13145 (candidate_1, preview-first flow); ledger updated candidate → corrected.
132+
Report: [`reviews/btc-4h-fib-20171228-correction-20260615.md`](reviews/btc-4h-fib-20171228-correction-20260615.md).
133+
3. **Chart-regression — DONE (spike + #F).** `research/render_summary.py` + golden JSON
134+
snapshots under `tests/research/snapshots/` (map/zoom/gallery; stdlib, no baselines).
135+
Pixel/`pytest-mpl` still deferred. Spike:
136+
[`reviews/chart-regression-strategy-20260615.md`](reviews/chart-regression-strategy-20260615.md).
137+
138+
No open implementation items remain in the #32 tooling track. **Corpus declared clean and
139+
locked** (integrity capstone 2026-06-15:
140+
[`reviews/btc-source-fib-corpus-integrity-20260615.md`](reviews/btc-source-fib-corpus-integrity-20260615.md)).
141+
**MTF confluence atlas in progress.** CP1 ([table](reviews/btc-mtf-confluence-table-20260615.md))
142+
+ CP2 ([sensitivity](reviews/btc-mtf-confluence-sensitivity-20260615.md)) DONE —
143+
`research/mtf_confluence.py` (stdlib). CP2: c001 robust 4-TF; **c002 chaining-dependent** (not
144+
tight 4-TF); fixed-band 188 clusters @0.005; chaining 14% @0.005→26% @0.01. **Next: CP3 visual
145+
atlas (conditional)** — render fixed-band clusters + annotate `price_span_log`; no signal/edge.
146+
147+
**Deferred:** 1H source labeling — 4H is the lowest active timeframe; fetch 1H cache first
148+
(`data.fetch --timeframes 1h`). Separate decision before starting.
124149

125150
## Guardrails
126151

@@ -257,12 +282,13 @@ $env:PYTHONDONTWRITEBYTECODE = "1"
257282
- **BTC/USD 4H source-fib phase is complete.** 366 source fibs (2017-01-05 → 2026-06-05),
258283
up=169 / down=197, 366/366 schema PASS (2026-06-12). Do not resume unless a bug or gap
259284
is found. 4H is the current lowest active timeframe (1H paused).
260-
- **4H visual confirmation Tier 1 is built** (`research/fourh_source_fib_map.py`,
261-
2026-06-12). Annual combined 4H maps, 366/366 drawn across 11 groups. Next is **human
262-
review of the generated maps**, then Tier 2 (`fourh_source_fib_zoom.py`) on-demand —
263-
2017_h2 (~103 fibs) is already flagged as needing per-fib zoom. Do not start with 1H.
264-
Do not start with reaction-review. Design:
265-
[`reviews/btc-4h-visual-confirmation-design-20260612.md`](reviews/btc-4h-visual-confirmation-design-20260612.md).
285+
- **4H visual confirmation Tier 1 + Tier 2 sample-pass complete** (2026-06-15). Tier 1:
286+
`research/fourh_source_fib_map.py`, 11 annual groups, 366/366 drawn. Tier 2:
287+
`research/fourh_source_fib_zoom.py`, 103+37 fibs rendered; first manual sample-pass (8
288+
fibs) shows no suspicious labels. Two watchlist items: `20171228` (short-span) and
289+
body/close vs wick convention (undocumented). Do not start with 1H. Do not start with
290+
reaction-review. Review:
291+
[`reviews/btc-4h-tier2-sample-review-20260615.md`](reviews/btc-4h-tier2-sample-review-20260615.md).
266292
- Do not auto-fib. Do not infer anchors. Keep the four flows distinct: 1M source /
267293
1M→1W projection / true 1W source / true 1D source fibs.
268294

docs/research_wiki/log-archive-pre-btc-reset-part1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Archived wiki log (pre-BTC monthly reset, part 1)
22

3-
Moved from log.md on 2026-06-09. Part 1 of 2. Next: [part 2](log-archive-pre-btc-reset-part2.md).
3+
Moved from log.md on 2026-06-09. Part 1 of 3. Next: [part 2](log-archive-pre-btc-reset-part2.md).
44

55
## [2026-06-05] decision | MTF fib level projection — design + inspection
66

docs/research_wiki/log-archive-pre-btc-reset-part2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Archived wiki log (pre-BTC monthly reset, part 2)
22

3-
Part 2 of 2. Previous: [part 1](log-archive-pre-btc-reset-part1.md).
3+
Part 2 of 3. Previous: [part 1](log-archive-pre-btc-reset-part1.md). Next: [part 3](log-archive-pre-btc-reset-part3.md).
44

55
- `.cursor/rules/repo-aware-coding-agent.mdc` (always apply)
66
- `docs/agent/REPO_AWARE_AGENT.md` — Cursor settings, `@` context, User Rules snippet

0 commit comments

Comments
 (0)