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

@@ -19,7 +19,6 @@ from datetime import date, datetime, time, timedelta
from pathlib import Path
from openpyxl import Workbook
from openpyxl.chart import LineChart, Reference
from openpyxl.formatting.rule import CellIsRule
from openpyxl.styles import Alignment, Border, Font, PatternFill, Side
from openpyxl.utils import get_column_letter
@@ -1746,49 +1745,8 @@ def build_dashboard(wb: Workbook) -> None:
for r in range(5, 5 + len(metrics)):
ws.row_dimensions[r].height = 75
# Equity curve chart — 5 linii
chart = LineChart()
chart.title = "Equity Curve — 5 strategii"
chart.style = 12
chart.y_axis.title = "Balance ($)"
chart.x_axis.title = "Trade #"
chart.height = 12
chart.width = 24
data = Reference(
wb["Trades"],
min_col=_col_to_int(COL[f"Bal_{STRAT_KEYS[0]}"]),
max_col=_col_to_int(COL[f"Bal_{STRAT_KEYS[-1]}"]),
min_row=1,
max_row=MAX_ROWS + 1,
)
chart.add_data(data, titles_from_data=True)
cats = Reference(
wb["Trades"], min_col=1, max_col=1,
min_row=2, max_row=MAX_ROWS + 1,
)
chart.set_categories(cats)
ws.add_chart(chart, "V4")
# Equity curve prop — al doilea chart, separat de modelul abstract
chart_prop = LineChart()
chart_prop.title = "Equity Curve — Prop (cont real)"
chart_prop.style = 12
chart_prop.y_axis.title = "Balance Prop ($)"
chart_prop.x_axis.title = "Trade #"
chart_prop.height = 12
chart_prop.width = 24
data_prop = Reference(
wb["Trades"],
min_col=_col_to_int(COL[f"BalProp_{STRAT_KEYS[0]}"]),
max_col=_col_to_int(COL[f"BalProp_{STRAT_KEYS[-1]}"]),
min_row=1,
max_row=MAX_ROWS + 1,
)
chart_prop.add_data(data_prop, titles_from_data=True)
chart_prop.set_categories(cats)
ws.add_chart(chart_prop, "V30")
# Notă: graficele de echitate au fost eliminate (nu sunt folosite). Dashboard-ul
# rămâne pur tabelar — metrici + breakdown-uri + ferestre + compliance prop.
# ---------------------------------------------------------------------------
@@ -1797,13 +1755,16 @@ def build_dashboard(wb: Workbook) -> None:
def build_workbook() -> Workbook:
# backtest.xlsx = doar Config + Trades (fișierul editat zilnic, ușor/rapid).
# Dashboard-ul trăiește separat în data/Dashboard.xlsx, generat la comandă de
# scripts/generate_dashboard.py (vezi refresh_dashboard.bat). build_dashboard()
# rămâne aici și e refolosit de acel script.
wb = Workbook()
default = wb.active
wb.remove(default)
build_config(wb)
build_trades(wb)
build_dashboard(wb)
wb.active = wb.sheetnames.index("Dashboard")
wb.active = wb.sheetnames.index("Trades")
return wb