stocks / static /backtest.html
user
python version
ee446e8
Raw History Blame Contribute Delete
13.4 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<title>Backtesting - LT</title>
<meta name="description" content="Validate trading strategies with historical data backtesting">
<meta name="theme-color" content="#131722">
<link rel="manifest" href="/static/manifest.json">
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<link rel="apple-touch-icon" href="/static/icons/icon-192.png">
<link rel="stylesheet" href="/static/css/common.css">
<link rel="stylesheet" href="/static/css/backtest.css">
<!-- The Reports tab moved in from its own page, so the stylesheet comes
with it. Only loaded here for the selectors the tab panel uses; the
module behind it is imported when the tab is first shown. -->
<link rel="stylesheet" href="/static/css/reports.css">
<link rel="stylesheet" href="/static/css/risk-modal.css">
<link rel="stylesheet" href="/static/css/chat-modal.css">
<link rel="preconnect" href="https://unpkg.com">
<script defer src="https://unpkg.com/lightweight-charts@5.0.0/dist/lightweight-charts.standalone.production.js"></script>
</head>
<body class="backtest-page" data-page="backtest">
<nav class="main-nav" id="main-nav"></nav>
<div class="page-wrapper">
<!-- ═══ Page header: the title and the tab control on one compact row. The
active tab lives in ?tab=, so the URL is the state and /reports
redirects onto it. ═══ -->
<header class="page-header backtest-page-header">
<h1 class="page-header__title">Backtest</h1>
<div class="backtest-tabs" id="backtest-tabs" role="tablist" aria-label="Backtesting sections">
<button type="button" class="backtest-tab active" id="backtest-tab-btn-backtest" role="tab"
aria-selected="true" aria-controls="backtest-panel-backtest" data-tab="backtest">Backtest</button>
<button type="button" class="backtest-tab" id="backtest-tab-btn-reports" role="tab"
aria-selected="false" aria-controls="backtest-panel-reports" data-tab="reports">Screener</button>
</div>
</header>
<!-- ═══ Tab panel: backtest run ═══ -->
<div class="backtest-tab-panel backtest-tab-panel--backtest" id="backtest-panel-backtest" role="tabpanel" aria-labelledby="backtest-tab-btn-backtest" data-tab="backtest">
<!-- The page is the run bar plus the workbench below it. The workbench
(the rows and the chart they produced) keeps the page: the
configuration is folded behind the bar's Edit control, so the chart
is on screen beside its rows instead of below a form. -->
<div class="bt-layout">
<!-- The run bar: what Start would replay (signal, window, universe), the
run's state and its controls, all on one wrapping line. Its Edit
control unfolds the configuration underneath. -->
<div class="bt-side" id="bt-side">
<div class="bt-summary">
<dl class="bt-summary__items">
<div class="bt-summary__item">
<dt>Signal</dt>
<dd id="bt-summary-signal"></dd>
</div>
<div class="bt-summary__item">
<dt>Window</dt>
<dd id="bt-summary-window"></dd>
</div>
<div class="bt-summary__item">
<dt>Universe</dt>
<dd id="bt-summary-universe"></dd>
</div>
</dl>
<button type="button" id="bt-config-toggle" class="btn btn-secondary" aria-expanded="false" aria-controls="bt-controls">Edit</button>
<div class="bt-actionbar">
<p class="bt-status" aria-live="polite"><span id="bt-status-message" class="bt-status-message">Ready</span></p>
<div class="bt-actions">
<button type="button" id="bt-start" class="btn btn-primary">Start</button>
<button type="button" id="bt-pause" class="btn btn-secondary" disabled>Pause</button>
<button type="button" id="bt-stop" class="btn btn-secondary">Stop</button>
<button type="button" id="bt-reset" class="btn btn-secondary" title="Reset saved selections">Reset</button>
</div>
</div>
</div>
<!-- Folded until the run bar's Edit control opens it, at every width. The
script owns the two classes that fold it; without the script the
panel stays in view, so the page still works. On desktop the three
groups sit side by side, on tablet and phone they stack, and on a
phone the panel is a full-screen sheet. -->
<section class="bt-controls" id="bt-controls" aria-label="Backtest configuration">
<div class="bt-controls__head">
<h2 class="bt-controls__title">Configuration</h2>
<button type="button" id="bt-config-close" class="btn btn-secondary">Close</button>
</div>
<fieldset class="bt-group">
<legend class="bt-group__legend" id="bt-group-signal">Signal</legend>
<label class="bt-field">
Alert (DSL)
<div class="bt-alert-row">
<select id="bt-alert" class="select-field" aria-describedby="bt-alert-summary"></select>
<button id="bt-alert-manage" class="btn btn-secondary " type="button" aria-expanded="false" aria-controls="bt-alert-editor-section" title="Define or edit signal alerts">Edit</button>
</div>
<div id="bt-alert-summary" class="bt-alert-summary" role="note"></div>
<div id="bt-run-live" class="bt-run-live"></div>
</label>
</fieldset>
<fieldset class="bt-group">
<legend class="bt-group__legend" id="bt-group-session">Session window</legend>
<div class="bt-group__fields">
<label class="bt-field">
Date
<input type="date" id="bt-date" class="input-field">
</label>
<label class="bt-field">
From
<input type="time" id="bt-from" class="input-field">
</label>
<label class="bt-field">
To
<input type="time" id="bt-to" class="input-field">
</label>
<label class="bt-field">
Timeframe
<select id="bt-timeframe" class="modal-input">
<option value="1M">1M</option>
<option value="5M">5M</option>
<option value="15M" selected>15M</option>
<option value="30M">30M</option>
<option value="1H">1H</option>
<option value="4H">4H</option>
<option value="1D">1D</option>
</select>
</label>
</div>
</fieldset>
<fieldset class="bt-group">
<legend class="bt-group__legend" id="bt-group-universe">Universe</legend>
<div class="bt-group__fields bt-group__fields--universe">
<label class="bt-field">
Symbols
<input type="text" id="bt-symbols" class="input-field" placeholder="AAPL, TSLA, NVDA">
</label>
<!-- The candidate filter is an optional DSL filter; it is
secondary to the primary workflow (pick a signal, set
the session window, enter symbols, run), so it lives
behind the shared Advanced disclosure. -->
<details class="ui-disclosure">
<summary class="ui-disclosure__summary">More</summary>
<div class="ui-disclosure__body">
<label class="bt-field">
Candidate filter (DSL, optional)
<textarea id="bt-candidate-filter-expression" class="filter-textarea" spellcheck="false" rows="2"></textarea>
</label>
</div>
</details>
</div>
</fieldset>
</section>
</div>
<div class="bt-main">
<!-- Warnings and the candidate summary land at the top of the results
column, above the workbench. -->
<div id="bt-notices" class="bt-notices"></div>
<!-- The DSL alert editor, rendered inline by
features/shared/raw-alert-config-editor.js (shared with the
dashboard widget modal); hidden until "Edit" toggles it. -->
<div id="bt-alert-editor-host" class="bt-alert-editor-host"></div>
<!-- Hidden until a run exists: before the first Start there is no
progress to show, so "0/0" would only read as a broken counter. -->
<div class="bt-progress hidden" id="bt-progress">
<div class="bt-progress-track">
<div id="bt-progress-bar" class="bt-progress-fill"></div>
</div>
<span id="bt-progress-label">0/0</span>
</div>
<!-- Phone only: the results header is hidden there, so this select
carries the same sort state (features/backtest/result-sort.ts). -->
<div class="bt-sort-by">
<label class="bt-sort-by__label" for="bt-sort-by">Sort by</label>
<select id="bt-sort-by" class="select-field select-field--sm"></select>
</div>
<!-- The workbench: the rows on the left and the chart of the selected
row on the right, sharing one height on desktop so a click on a row
shows its chart beside the table instead of below the fold. The
seam under the chart resizes the pair (features/backtest/backtest-page.ts). -->
<div class="bt-workbench" id="bt-workbench">
<div class="bt-results data-table-wrap">
<table class="bt-results-table data-table">
<thead id="bt-results-head"></thead>
<tbody id="bt-results-body">
<tr class="bt-empty-row">
<td colspan="8">
<div class="bt-empty">
<p class="bt-empty__title">No signals yet</p>
<p class="bt-empty__body">Choose a signal and a session window, add symbols or a candidate filter, then click Start. Each match appears here as its own row.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Empty until a result row is opened: the card is kept in place so
the chart keeps its size, but it stays out of sight, and the
prompt takes its space, until openChartForSignal clears is-empty. -->
<div class="bt-chart is-empty" id="bt-chart">
<button type="button" id="bt-chart-close" class="btn btn-secondary bt-chart__close">Close chart</button>
<stock-chart-card id="bt-chart-card" context="backtest" fill></stock-chart-card>
<div class="bt-chart-empty" id="bt-chart-empty">
<div class="bt-empty">
<p class="bt-empty__title">No chart selected</p>
<p class="bt-empty__body">Select a result row to see its chart.</p>
</div>
</div>
<!-- biome-ignore lint/a11y/useSemanticElements: a drag seam is a separator, not a thematic break -->
<div class="panel-resize-handle panel-resize-handle--row" id="bt-chart-resize" role="separator" aria-label="Resize the results chart"></div>
</div>
</div>
<!-- /.bt-workbench -->
</div>
<!-- /.bt-main -->
</div>
<!-- /.bt-layout -->
</div>
<!-- ═══ Tab panel: Reports ═══
Markup moved verbatim from the retired static/reports.html, ids
and class names included, so features/reports/reports-page.ts
needed no edits to run here. The module behind it is imported the
first time this tab is shown (see features/backtest/tabs.ts). -->
<div class="backtest-tab-panel hidden" id="backtest-panel-reports" role="tabpanel" aria-labelledby="backtest-tab-btn-reports" data-tab="reports">
<div id="reports-list"></div>
</div>
</div>
<script type="module" src="/static/js/pages/backtest.js"></script>
</body>
</html>