Spaces:
Running on Zero
Running on Zero
| # Design reference β Backtest Lab | |
| Extracted from `Bit Trading Portal Dashboard/Backtest Lab.dc.html` plus the Bit | |
| design system (`_ds/bit-design-system-b707c3d1β¦`). This file is the contract the | |
| Gradio UI is built against; `assets/tokens/*.css` and `assets/fonts/*` are | |
| vendored verbatim from that design system. | |
| ## Design system | |
| Dark-first, terminal-flavoured. Tokens only β components never use raw colors. | |
| | Role | Token | Value | | |
| |---|---|---| | |
| | Canvas | `--bg-canvas` | `#161512` (stone-950) | | |
| | Panel | `--bg-panel` | `#1d1c18` (stone-900) | | |
| | Raised | `--bg-raised` | `#24221d` (stone-850) | | |
| | Border subtle / default | `--border-subtle` / `--border-default` | `#2c2a24` / `#3d3a32` | | |
| | Text primary / secondary / tertiary | | `#f7f4ec` / `#b6b09a` / `#6f6a56` | | |
| | Primary accent | `--accent-amber` / `-strong` | `#af9209` / `#cfab0a` | | |
| | Secondary accent | `--accent-moss` / `-strong` | `#68781e` / `#7d901f` | | |
| | Up / down | `--fin-up` / `--fin-down` | `oklch(66% .22 149)` / `oklch(62% .26 24)` | | |
| Colorblind mode (`[data-colorblind=true]`) swaps up/down to blue/orange, and | |
| direction is **also** marked with β²/βΌ glyphs β never color alone. | |
| Fonts: headings `Styrene A` (400), body system sans (300), `JetBrains Mono` for | |
| numbers, `Mac Minecraft` for the 8β10px pixel labels. Sizes are small: | |
| `--text-2xs:8px β¦ --text-base:12px β¦ --text-4xl:62px`. | |
| Radii are near-square (`--radius-sm:4px`, `--radius-md:8px`); panels are a 1px | |
| border, no drop shadows (`--shadow-panel: 0 0 0 1px var(--border-default)`). | |
| Section headings are ALL-CAPS Styrene with `--tracking-wide`; micro-labels are | |
| uppercase Mac Minecraft with `--tracking-wider`. | |
| ## Layout | |
| Three zones; left `286px`, right `306px` (collapses to `46px`), center fluid. | |
| - **Top bar** β BIT mark, `BIT / Backtest Lab`, context chip | |
| (`BTC-USD Β· 1H Β· 2021-08-15 β 2026-08-15 Β· WALK-FORWARD`), run-status chip, | |
| elapsed (`~4S`), amber **βΆ Run backtest**, Display menu (Dark mode / | |
| Colorblind-safe prices, footnote `UP/DOWN ALSO MARKED β² βΌ`), `Portal β`. | |
| - **Left β Strategy Builder** (`CFG #0142`), five numbered collapsible sections: | |
| 1. Strategy β preset select + params | |
| 2. Universe & Data β ticker chips (`+ ticker`), Asset class segmented | |
| (Crypto/Equities/Both), Timeframe chips, Date range (`1Y 3Y 5Y Max`), | |
| Regime filter (`Bull only / Bear only / Chop only`, `NEW` badge) | |
| 3. Costs & Execution β Commission/side `0.10%`, Slippage `5 BPS`, | |
| slippage model (`Fixed bps / Volume-scaled / Spread-based`), | |
| fill (`Next bar open / Same bar close`), funding. | |
| Warning: **"Costs on. Turning these off is how strategies lie to you."** | |
| 4. Sizing & Risk β sizing (`Fixed % / Kelly fraction / Vol-target 15% ann.`), | |
| leverage `1Xβ¦3X`, Max position `35%`, Max concurrent `2` | |
| 5. Validation β `TRAIN 12MO Β· TEST 3MO Β· ROLL 3MO`, β TRAIN / β TEST bands, | |
| OOS holdout `LAST 6MO` | |
| Footer: `Save config`, `Share link`. | |
| - **Center β Results Canvas**, tabs: `Overview Β· Trades Β· Comparison Β· Robustness Β· Report` | |
| - **Right β Run Manager** β `RUNNING Β· {progress}`, Run history (`n/6 SELECTED`, | |
| star = favourite, Sharpe color-coded), Trending public configs, `Clone config`, | |
| `Metrics glossary`. | |
| - **Footer** β always visible: | |
| "Simulated results with modeled costs. Backtests are hypotheses, not promises. | |
| Past performance does not predict future results. Not financial advice." | |
| Right: `BITTRADING SDK 0.9.3`. | |
| ## States | |
| - **Empty**: "No run loaded" / "Configure a strategy on the left, or start from a | |
| worked example and edit it." + `Load example: Sentiment-Gated Momentum Β· BTC 1h` | |
| + shortcut hints `ββ΅ RUN`, `βS SAVE CONFIG`, `βK COMMANDS`. | |
| - **Loading**: staged labels β `Fetching data`, `Simulating N trades`, | |
| `Walk-forward window k/n`, `Computing robustness`. | |
| ## Tab contents | |
| **Overview** β stat band (each stat shows `IS x Β· OOS y`); `EQUITY CURVE` | |
| (`STRATEGY VS BUY & HOLD`, log-scale toggle, drawdown shading, hatched `HOLDOUT` | |
| band, `REGIME` strip); `UNDERWATER Β· MAX β23.6%`; `ROLLING 90D SHARPE Β· MEDIAN 1.24`; | |
| price+trades chart (`β² ENTRY Β· βΌ EXIT Β· HOLLOW = SHORT Β· HOVER A FLAG FOR THE TRADE CARD`); | |
| `NET P&L DISTRIBUTION`, `HOLDING PERIOD (HOURS)`, `MAE / MFE SCATTER`; | |
| `COSTS PAID TOTAL: $1,842` with the note that the costed number is the real one. | |
| **Trades** β `312 TOTAL Β· SHOWING 14`, `Export CSV β`, sortable columns: | |
| id, entry/exit time, side, entry/exit px, size, gross, costs, net, R, duration, | |
| MAE, trigger. | |
| **Comparison** β `Time-scale matrix` (`CELL = OOS SHARPE Β· CLICK TO LOAD RUN`, | |
| scale β0.5 β 2.0), `n/6 SELECTED`, small-multiples equity grid, overlaid | |
| cumulative return (`SHARED SCALE Β· OOS PERIOD SHADED`), metrics table | |
| (rows: Total return, CAGR, OOS Sharpe, Max drawdown, Win rate, Trades; best | |
| value amber+bold), `RETURN CORRELATION Β· ARE THESE THE SAME BET?`, | |
| `RETURN ACROSS REGIMES Β· BULL / BEAR / CHOP`. | |
| **Robustness** β `Overfit verdict` with grade + checklist; `PARAMETER SENSITIVITY Β· | |
| FAST MA Γ SLOW MA Β· OOS SHARPE` heatmap with `β‘ CHOSEN` marker; | |
| `MONTE CARLO Β· 1,000 TRADE RESHUFFLES` cone with `P5 / P50 / P95` and | |
| `P(RUIN > 30% DD)`; `WALK-FORWARD WINDOWS Β· OOS RETURN` bars with | |
| `CONSISTENCY 6/8 POSITIVE`; `SLIPPAGE STRESS Β· SHARPE VS BPS`. | |
| **Report** β prose summary, `EQUITY CURVE Β· STRATEGY VS BUY & HOLD`, | |
| `CONFIG SNAPSHOT`, verdict line, actions: `Export PDF`, `Publish to leaderboard`, | |
| `Publish to graveyard`, `Copy share link`, `Export trades CSV`, `Open in Colab`. | |
| ## Presets (design list) | |
| `SMA Crossover`, `RSI Mean Reversion`, `Bollinger Breakout`, `MACD Momentum`, | |
| `Sentiment-Gated Momentum`, `Chronos Forecast Follower`, `Pairs Trading`, | |
| `Buy & Hold (benchmark)`, `Custom (code)`. | |
| `Custom (code)` is shown **disabled** β see DECISIONS.md (D-004). Executing | |
| user-supplied strategy code is forbidden by the build spec, so the control is | |
| present but inert with an explanation rather than silently removed. | |
| ## Glossary copy (verbatim, used in the Run Manager tray) | |
| - **SHARPE** β Annualized mean excess return divided by return volatility. Above 1 is good; above 3 usually means a bug. | |
| - **SORTINO** β Sharpe with only downside deviation in the denominator. | |
| - **MAX DRAWDOWN** β Worst peak-to-trough decline of the equity curve. | |
| - **PROFIT FACTOR** β Gross profit over gross loss. Below 1.2 rarely survives real costs. | |
| - **R-MULTIPLE** β Trade P&L expressed in units of initial risk. | |
| - **MAE / MFE** β Worst and best unrealized excursion while the trade was open. | |
| - **WALK-FORWARD** β Train on a rolling window, test on the next unseen window, repeat. | |
| - **OOS** β Out of sample: data the parameters never saw during fitting. | |