separa Dashboard de Trades: backtest.xlsx 39MB -> 1MB

backtest.xlsx ramane doar Config + Trades (editat zilnic, rapid la salvat).
Dashboard-ul devine fisier separat data/Dashboard.xlsx, generat la comanda:

- scripts/generate_dashboard.py: citeste backtest.xlsx read-only/data_only,
  reutilizeaza build_dashboard() pe un sheet Trades static, scrie Dashboard.xlsx
- scripts/strip_dashboard.py: migrare unica prin chirurgie pe zip (pastreaza
  dropdown-urile x14 din Trades; openpyxl le-ar fi sters)
- refresh_dashboard.bat: wrapper dublu-click (regenereaza + deschide)
- build_workbook() nu mai include Dashboard; graficele de echitate eliminate
- data/Dashboard.xlsx ignorat (output regenerabil)

Sincronizare la comanda (nu live): ruleaza refresh_dashboard.bat dupa ce
salvezi backtest.xlsx in Excel.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marius
2026-06-01 23:52:58 +03:00
parent 8e51b7dc46
commit 45e6505afa
7 changed files with 374 additions and 49 deletions

View File

@@ -14,9 +14,12 @@ Documentation and UI strings are in **Romanian**; keep them Romanian when editin
```powershell
pip install openpyxl # one-time
python scripts/generate_template.py # regenerate data/backtest.xlsx
python scripts/generate_template.py # regenerate data/backtest.xlsx (Config + Trades only)
python scripts/generate_dashboard.py # regenerate data/Dashboard.xlsx din backtest.xlsx
```
`refresh_dashboard.bat` (rădăcina repo) = wrapper dublu-click: rulează `generate_dashboard.py` și deschide `Dashboard.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.
@@ -27,11 +30,11 @@ 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:
`build_workbook()` builds `data/backtest.xlsx` = **2 sheets only** (Config + Trades). `build_dashboard()` still lives here but is **no longer added to backtest.xlsx** — it is reused by `scripts/generate_dashboard.py` to build the separate `data/Dashboard.xlsx` (see "Dashboard separat" below).
- **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.
- **Dashboard** (`build_dashboard`, emitted into the separate `Dashboard.xlsx`) — reads from Trades ranges via `SUMIF`/`AVERAGEIF`/`COUNTIF`; renders metrics table, glossary, per-Session/Strategy/Indicator/Direction breakdowns, ferestre candidate, prop compliance. **No equity-curve chart** (removed — Dashboard is pure-tabular).
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["..."]`.
@@ -71,6 +74,28 @@ Totul se recalculează automat din `backtest.xlsx` (R/$ deja calculate de Excel;
**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.
## Dashboard separat (scripts/generate_dashboard.py)
`backtest.xlsx` ajunsese ~39 MB și se salva greu. Cauza NU erau tranzacțiile, ci **sheet-ul Dashboard** (~4.200 coloane-helper ascunse → ~2,1M celule cu formule în `calcChain.xml`). Soluție: Dashboard-ul a fost scos din fișierul editat zilnic într-un fișier separat, generat la comandă (același tipar ca Ferestre v2).
**Cele 3 fișiere:**
- `data/backtest.xlsx`**editat zilnic**, doar Config + Trades (~0.8 MB, rapid la salvat).
- `data/Dashboard.xlsx`**generat read-only** de `generate_dashboard.py` din backtest.xlsx. Conține un sheet `Trades` ascuns cu **valori statice** (copiate din cache-ul Excel) + sheet-ul Dashboard cu formulele reutilizate din `build_dashboard()`. Marius nu-l editează niciodată — se regenerează.
- `data/Ferestre_v2.xlsx` — analiza edge/fereastră (separată, vezi mai sus).
**Reluare după tranzacții noi:**
```powershell
# întâi: deschide & SALVEAZĂ backtest.xlsx în Excel (populează cache-ul de valori R_/$_/Bal_)
python scripts/generate_dashboard.py # sau dublu-click refresh_dashboard.bat
```
`generate_dashboard.py` citește `backtest.xlsx` **read-only, `data_only=True`** — ia valorile DEJA calculate de Excel (nu recalculează formule). **Constrângere:** dacă nu ai salvat în Excel după ultima editare, cache-ul lipsește și Dashboard-ul iese gol (aceeași condiție ca Ferestre v2).
**Sincronizare:** la comandă (rulezi scriptul/bat-ul), NU live. Marius a ales explicit acest model.
**Migrare unică — `scripts/strip_dashboard.py`:** scoate sheet-ul Dashboard din `backtest.xlsx` existent (39 MB → ~0.8 MB). NU folosește openpyxl pentru rescriere (ar șterge cele 12 dropdown-uri **x14** din Trades). Face **chirurgie pe zip**: elimină doar partea Dashboard + drawings/charts + `calcChain.xml` + definedName-ul orfan, lăsând XML-ul Config/Trades byte-cu-byte intact. Cere `--yes` și face backup automat. Alternativă 100% sigură: șterge tab-ul Dashboard manual în Excel (click-dreapta → Delete → Save). **Rulează doar cu acordul lui Marius** (e destructiv pe fișierul real).
**Escape hatch dimensiune Dashboard.xlsx:** `Config!B17` (Activează filtru Prima) = `NU` reduce drastic grid-ul de ferestre → Dashboard.xlsx mult mai mic/rapid.
## Reference docs
- `strategie_M2D.md` — M2D setup rules (color-coded dot bands on TF mare/mic, SL/TP placement, session filters).