Files
atm-backtesting/CLAUDE.md
Marius 0e03d32004 docs: CLAUDE.md — ghid pentru Claude Code (Excel-first journal, 5 strategii)
Bootstrap creat via /init. Surprinde:
- ce e repo-ul (jurnal Excel manual, nu pipeline automat — reboot-ul recent eliminat vision)
- regenerator-ul template + atenționarea că suprascrie data/backtest.xlsx
- arhitectura celor 3 sheets (Config / Trades / Dashboard) și lookup-ul COL
- 5 strategiile management cu STRAT_KEYS + R_FN
- STOPPING_RULE.md ca document semnat (thresholds fixe)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 19:24:05 +03:00

4.9 KiB

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.

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.