Files
atm-backtesting/CLAUDE.md
Marius 8e51b7dc46 analiza Ferestre v2: fereastra optima pe edge/durata/fiabilitate
Script nou generate_ferestre_v2.py (citeste backtest.xlsx read-only, scrie
data/Ferestre_v2.xlsx separat). Tabel unic cu toate variantele + validari
forward (lunar, train/test 70/30, walk-forward 3 felii) + bootstrap CI +
grafic echitate. Recomandari A (19:15-20:15) / B (19:45-21:45) / W (19:15-22:15).
Ghid de reluare in CLAUDE.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 11:36:11 +03:00

7.3 KiB
Raw Blame History

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What this repo is

A manual Excel-first backtesting journal for blackbox trading signals (M2D strategy primarily). There is no live data ingestion, no broker integration, no vision pipeline — the user types each trade into data/backtest.xlsx and Excel formulas compute everything else. The Python codebase is one script that regenerates the workbook template.

The project was recently rebooted (commit 0179217) — an earlier vision/screenshot extraction pipeline was removed in favor of this manual Excel approach. Do not reintroduce vision/OCR/auto-extraction features unless explicitly asked.

Documentation and UI strings are in Romanian; keep them Romanian when editing.

Commands

pip install openpyxl                       # one-time
python scripts/generate_template.py        # regenerate data/backtest.xlsx

No test suite, linter, or build step exists. The only "build" is regenerating the Excel.

Destructive caveat: generate_template.py overwrites data/backtest.xlsx with no prompt. The user's logged trades live in that file. Before running it (or asking the user to), confirm they have a backup or that the file is empty/sample-only.

Architecture

Three artifacts work together; understand all three before editing any:

1. scripts/generate_template.py — the only code

Builds a 3-sheet workbook via openpyxl:

  • Config sheet — editable params (Account Size, Risk %) and dropdown source lists.
  • Trades sheet — MAX_ROWS=500 pre-populated rows. Yellow cells = user input (date, time, strategy, indicator, TF, direction, SL/TP %, outcome). Blue cells = derived via formula (Zi, Sesiune, then per-strategy R_*, $_*, Bal_*). Grey cells = helper columns (Win_*, Peak_*, DD_*) consumed by Dashboard.
  • Dashboard sheet — reads from Trades ranges via SUMIF/AVERAGEIF/COUNTIF; renders metrics table, glossary, per-Session/Strategy/Indicator/Direction breakdowns, and a 5-line equity-curve chart.

Column-name → letter mapping is held in the COL dict, built from TRADES_HEADERS = INPUT_HEADERS + DERIVED_HEADERS + HELPER_HEADERS. Never hardcode column letters — adding/reordering a header shifts every letter. Always look up via COL["..."].

2. The 5 management strategies — core domain concept

Every trade is simulated through 5 management overlays in parallel. Keys (STRAT_KEYS) and their R-multiple formula builders (R_FN) must stay in sync:

Key Label Formula entry point
tp0only TP0 only _f_r_tp0only
tp1only TP1 only _f_r_tp1only
tp2only TP2 only _f_r_tp2only
hybrid_be Hybrid + BE _f_r_hybrid_be
hybrid_nobe Hybrid no BE _f_r_hybrid_nobe

For each strategy and each trade row, six columns are emitted: R_*, $_*, Bal_*, Win_*, Peak_*, DD_*. Adding a 6th strategy means: append to STRAT_KEYS + STRAT_LABELS, add an _f_r_<key> formula, register it in R_FN, and the rest (Trades columns, Dashboard table column, equity-curve series) flows automatically. The R-multiple formulas encode trader assumptions — the truth table is documented in README.md and STOPPING_RULE.md; changing one is a strategy decision, not a refactor.

3. Session derivation (M2D-specific)

The Sesiune column is computed by _f_session from Data + Ora RO (Romanian time) using nested IFs encoding the M2D session windows (A1/A2/A3/B/C/D/Other). The buckets and times come from strategie_M2D.md. If asked to add a new session bucket, edit _f_session and SESSIONS together — Dashboard's PER SESIUNE breakdown iterates over SESSIONS.

Decision gates — STOPPING_RULE.md

STOPPING_RULE.md is a signed document (the user committed it as a commitment). It defines GO LIVE / EXTEND / ABANDON thresholds: N≥40, WR≥55%, Expectancy≥+0.20R. Treat these numbers as fixed unless the user explicitly asks to renegotiate them — do not "improve" them in passing.

Ferestre v2 — analiză edge/fereastră (scripts/generate_ferestre_v2.py)

Analiză separată care găsește fereastra de timp (ora RO) cu cel mai bun raport edge / nr. tranzacții / durată, fără să breach-uiască contul prop. Citește data/backtest.xlsx read-only și scrie un fișier nou data/Ferestre_v2.xlsx (NU atinge workbook-ul cu tranzacții; date_grafic rămâne sheet vizibil ca să se randeze chart-ul).

Reluare după ce Marius adaugă tranzacții noi:

python scripts/generate_ferestre_v2.py

Totul se recalculează automat din backtest.xlsx (R/$ deja calculate de Excel; scriptul nu recalculează formule). Conține: Concluzii, Tabel unic cu toate variantele, validări Forward 1 (lunar) / Forward 2 (train-test 70/30) / Walk-forward (3 felii) pe toate ferestrele, bootstrap CI, calendar, grafic echitate.

ÎNAINTE de analiză — verifică typo-uri de tastare în Trades (TP%/SL% cu zecimală lipsă umflă fals edge-ul). Cele găsite și corectate manual: #314 (TP2 17→0.17), #298 (TP0 0.5→0.05), #240 (TP1 0.8→0.08). La date noi, caută valori TP/SL ≥1 sau TP0>TP1>TP2 inversate și confirmă cu Marius înainte de a corecta.

Findings curente (330 trade-uri, ianmai 2026, doar hybrid_be e pozitiv pe ansamblu ~+0.05R): edge-ul vine din CÂND, nu din management; 18:0019:00 RO = zonă moartă; ora de start optimă = 19:15. Trei configurații recomandate: A 19:1520:15 (1h, edge max/timp min), B 19:4521:45 prima (cea mai robustă pe toate validările), W 19:1522:15 prima (volum/bani max raportat la timp; +30 min până la 22:45 aduc doar ~+$61). Filtrele direcționale (buy) par mai bune dar pică out-of-sample. Edge subțire → ipoteze de confirmat live.

Reference docs

  • strategie_M2D.md — M2D setup rules (color-coded dot bands on TF mare/mic, SL/TP placement, session filters).
  • calendar_evenimente.yaml — manual news calendar (FOMC/NFP/CPI). Read-only context; not parsed by code.
  • README.md — user-facing workflow + R-multiple truth table.

Working in this repo

  • The user is Marius, a discretionary trader doing his own backtest, not an engineer building a product. Prefer minimal, legible changes to the Excel template over abstractions. The audience is one person logging trades, not a team.
  • When changing formulas in generate_template.py, regenerate the workbook and inspect at least one row's outputs before declaring done — a formula typo silently breaks the entire downstream Dashboard.
  • The git user is Marius on branch master (not main); PRs are not the workflow here, direct commits to master are.

gstack

Use the /browse skill from gstack for all web browsing. Never use mcp__claude-in-chrome__* tools.

Available gstack skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, /design-consultation, /design-shotgun, /design-html, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /connect-chrome, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /setup-gbrain, /retro, /investigate, /document-release, /document-generate, /codex, /cso, /autoplan, /plan-devex-review, /devex-review, /careful, /freeze, /guard, /unfreeze, /gstack-upgrade, /learn.