stocks / static /css /backtest.css
user
python version
ee446e8
Raw History Blame Contribute Delete
18.2 kB
/* Backtesting page β€” header, run bar, folded configuration, results workbench. */
/* ── Page header and tabs ──
The title and the tab control share one compact row: no explanation line,
no gap under the title. The row wraps only when the tabs cannot fit beside
the title, which the phone width forces. */
.backtest-page-header {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: var(--space-xs) var(--space-md);
margin-bottom: var(--space-sm);
padding-bottom: var(--space-xs);
}
.backtest-page-header .page-header__title {
margin: 0;
}
/* A compact segmented control rather than three stretched buttons: the tabs
are sections of one page, so they read as one control. The active tab is the
accent fill; the rest stay quiet until hovered. */
.backtest-tabs {
display: inline-flex;
max-width: 100%;
gap: var(--radius-sm);
padding: var(--space-2xs);
margin: 0;
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-md);
overflow-x: auto;
}
.backtest-tab {
min-height: var(--tab-height);
padding: 0 var(--space-md);
background: transparent;
border: 0;
border-radius: var(--radius-sm);
color: var(--text-muted);
font-family: var(--font-sans);
font-size: var(--tab-font-size);
font-weight: 600;
white-space: nowrap;
cursor: pointer;
transition: background var(--transition-fast), color var(--transition-fast);
}
.backtest-tab:hover {
background: var(--overlay-1);
color: var(--text);
}
.backtest-tab:focus-visible {
outline: var(--radius-sm) solid var(--accent);
outline-offset: var(--radius-sm);
}
.backtest-tab.active {
background: var(--accent);
color: var(--on-accent);
}
/* ── Layout ──
One column everywhere: the run bar, then the workbench. The configuration
is folded under the run bar instead of holding a column of its own, which is
what leaves the page's height to the table and its chart. */
.bt-layout {
display: grid;
gap: var(--space-md);
min-width: 0;
}
.bt-side {
display: grid;
gap: var(--space-sm);
min-width: 0;
}
.bt-main {
display: grid;
gap: var(--space-md);
/* The results table is wider than its column and scrolls inside it; without
this the track is forced out to the table's min-content width. */
min-width: 0;
}
/* The viewport the run tab spends outside the workbench: the page-wrapper's
top and bottom padding, the header row (title and tabs) and the run bar with
its gap. Measured at 1440x900, where the workbench starts at y=115 and the
wrapper closes 32px below it. It is the default height only: a drag on the
seam stores --bt-chart-height, which wins over this. */
.backtest-tab-panel--backtest {
--bt-run-chrome: 147px;
}
/* ── Run bar ──
The whole run in one wrapping line: what Start would replay (signal, window,
universe), the Edit control that unfolds the configuration, the run's state
and its controls. It is built from the fields themselves, so it can only ever
say what Start would run. */
.bt-summary {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-sm) var(--space-md);
padding: var(--space-sm) var(--space-md);
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-xl);
}
.bt-summary__items {
display: flex;
flex: 1 1 auto;
flex-wrap: wrap;
gap: var(--space-xs) var(--space-md);
margin: 0;
min-width: 0;
}
.bt-summary__item {
display: flex;
align-items: baseline;
gap: var(--space-xs);
min-width: 0;
}
.bt-summary__item dt {
font-size: var(--font-xs);
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.05em;
font-weight: 600;
}
.bt-summary__item dd {
margin: 0;
min-width: 0;
font-size: var(--font-sm);
color: var(--text);
overflow-wrap: anywhere;
}
/* The run's state and its controls, at the bar's trailing edge. */
.bt-actionbar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: var(--space-sm) var(--space-md);
margin-left: auto;
}
.bt-status {
display: flex;
align-items: center;
gap: var(--space-xs);
margin: 0;
min-width: 0;
font-size: var(--font-sm);
color: var(--text-secondary);
}
.bt-status::before {
content: "";
flex: 0 0 auto;
width: var(--space-sm);
height: var(--space-sm);
border-radius: 50%;
background: var(--text-dim);
}
.bt-actions {
display: flex;
flex-wrap: wrap;
gap: var(--space-sm);
}
.bt-alert-row {
display: flex;
align-items: center;
gap: var(--space-xs);
}
.bt-alert-row .select-field {
flex: 1;
min-width: 0;
}
.bt-alert-summary {
font-size: var(--font-xs);
margin-top: var(--space-xs);
line-height: 1.35;
overflow-wrap: anywhere;
}
.bt-alert-summary--selected {
color: var(--text-secondary);
}
.bt-alert-summary--empty {
color: var(--text-dim);
font-style: italic;
}
.bt-run-live {
font-size: var(--font-xs);
margin-top: var(--space-xs);
color: var(--text-dim);
}
.bt-run-live a {
color: var(--accent);
text-decoration: none;
}
.bt-run-live a:hover {
text-decoration: underline;
}
/* Warnings and the candidate summary sit under the run bar, one per row. */
.bt-notices {
display: grid;
gap: var(--space-sm);
}
.bt-notices:empty {
display: none;
}
/* The editor host only wraps the alert editor section: it contributes no box
of its own, so a closed editor adds no gap above the workbench and an open
one takes its own row. */
.bt-alert-editor-host {
display: contents;
}
.bt-progress {
display: flex;
align-items: center;
gap: var(--space-sm);
}
.bt-status-message {
color: inherit;
font-size: var(--font-sm);
}
/* Phone-only sort control (see .bt-sort-by in the phone block below). */
.bt-sort-by {
display: none;
}
/* ── Configuration ──
Three groups read top to bottom: the signal, the session window, the
universe. Folded behind the run bar's Edit control at every width: the
script sets .is-collapsible on the bar's wrapper, and without the script the
panel stays in view so the page still works. On desktop the groups sit side
by side, so an open panel costs one row of fields rather than a column. */
.bt-controls {
display: grid;
gap: var(--space-md);
padding: var(--space-md);
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-xl);
}
.bt-side.is-collapsible:not(.is-open) .bt-controls {
display: none;
}
.bt-controls__head {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--space-md);
}
.bt-controls__title {
margin: 0;
font-size: var(--font-md);
font-weight: 600;
color: var(--text);
}
.bt-group {
display: grid;
gap: var(--space-sm);
min-width: 0;
}
/* The groups are fieldsets (native grouping for their legend); reset the UA box so they
lay out exactly as the old divs did. */
fieldset.bt-group {
border: 0;
margin: 0;
padding: 0;
}
legend.bt-group__legend {
float: none;
padding: 0;
width: auto;
}
/* A small caption over each group, the same treatment as a field label on the
Reports tab, so the three groups read as sections rather than loose fields. */
.bt-group__legend {
margin: 0;
font-size: var(--font-xs);
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.05em;
font-weight: 600;
}
.bt-group__fields {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--space-md);
align-items: end;
}
.bt-group__fields--universe {
grid-template-columns: minmax(0, 1fr);
align-items: start;
}
.bt-field {
display: flex;
flex-direction: column;
gap: var(--space-xs);
min-width: 0;
font-size: var(--font-sm);
color: var(--text-secondary);
}
.bt-field input,
.bt-field select,
.bt-field textarea {
width: 100%;
min-width: 0;
box-sizing: border-box;
}
/* ── Workbench ──
The rows and the chart they produced share one box: stacked on a narrow
reading, side by side on desktop, where a single height makes the chart
visible beside the table instead of below it. The seam under the chart
resizes both (features/backtest/backtest-page.ts writes the property). */
.bt-workbench {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: var(--space-md);
min-width: 0;
}
/* ── Results ──
A table with a sticky header. Stacked under the chart, the body scrolls
inside its own height cap, so the header stays in view and the chart keeps
its place below. */
.bt-results {
max-height: 60vh;
overflow: auto;
border: 1px solid var(--border);
border-radius: var(--radius-xl);
}
.bt-results-table {
width: 100%;
font-size: var(--font-md);
}
.bt-results-table th,
.bt-results-table td {
border-bottom: 1px solid var(--border);
white-space: nowrap;
}
/* Numbers read down a column when they share one alignment. */
.bt-num {
text-align: right;
font-variant-numeric: tabular-nums;
}
/* The empty state is a block of prose, not a sentence in a cell: it has to
wrap, so the cell's nowrap is lifted for it alone. */
.bt-results-table .bt-empty-row td {
white-space: normal;
border-bottom: 0;
}
/* Shared empty-state copy for the results table and the chart area: a heading
that says what is missing and a line that says what to do next. */
.bt-empty {
max-width: 56ch;
padding: var(--space-lg) var(--space-md);
}
.bt-empty__title {
margin: 0 0 var(--space-xs);
color: var(--text);
font-size: var(--font-md);
font-weight: 600;
}
.bt-empty__body {
margin: 0;
color: var(--text-muted);
font-size: var(--font-sm);
line-height: 1.5;
}
.bt-row {
cursor: pointer;
}
.bt-row:hover {
background: var(--bg-input);
}
.bt-row--active {
background: var(--bg-input);
}
/* The accent bar sits on the first cell: a box-shadow on the row itself does
not paint in every browser, and a cell does. */
.bt-row--active td:first-child {
box-shadow: inset var(--radius-sm) 0 0 var(--accent);
}
.bt-row--clickable:hover {
background: var(--bg-input);
}
.bt-row--clickable:focus-visible {
outline: var(--radius-sm) solid var(--accent);
outline-offset: -2px;
}
.bt-alert--up {
color: var(--success);
}
.bt-alert--down {
color: var(--danger);
}
/* ── Chart ── */
.bt-chart {
/* stock-chart-card[fill] sets height:100% on itself β€” without an explicit
(not min-) height here that resolves to 0 and the canvas never renders. */
height: var(--bt-chart-height, var(--chart-height-default));
position: relative;
}
/* Before a row is opened there is no symbol to chart. The card keeps its box
(visibility, not display, so the chart's size is settled when it appears) and
the prompt fills the same box, so the empty state takes the chart's place. */
.bt-chart.is-empty stock-chart-card {
visibility: hidden;
}
.bt-chart-empty {
display: none;
}
.bt-chart.is-empty .bt-chart-empty {
position: absolute;
inset: 0 0 var(--space-md);
display: flex;
align-items: center;
justify-content: center;
text-align: center;
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-xl);
}
.bt-chart.is-empty .bt-empty {
margin: 0 auto;
}
/* The close control only exists for the phone sheet (see the phone block). */
.bt-chart__close {
display: none;
}
/* Bottom-edge seam: the seam belongs to the chart's own bottom edge, so
dragging it down makes the workbench taller. */
.bt-chart > .panel-resize-handle--row {
top: auto;
bottom: 0;
}
/* ── Research tab: the study's own full-height layout ──
Research moved in from its own page, so it is a tab here; the active one is
in ?tab= (see features/backtest/tabs.ts). The study fills the viewport on a
page of its own, but hosted it sits below this tab bar inside the page
wrapper, so it declares the chrome above it. The Trades panel already does
the same for its own full-height layout, and research.css reads this
variable, defaulting to 0px so the study still fills a bare viewport. */
.backtest-tab-panel--research {
--research-layout-offset: calc(var(--space-xxl) * 2 + var(--space-xl) + var(--space-lg));
}
/* ── Tablet and phone touches ──
Below the desktop cut the workbench is stacked, so the chart keeps its own
height and the table keeps its cap. Controls grow to the touch minimum. */
@media (width <= 1024px) {
.bt-summary .btn,
.bt-controls .btn,
.bt-side .input-field,
.bt-side .select-field,
.bt-side .modal-input,
.bt-side .filter-textarea {
min-height: var(--touch-min);
}
}
/* Desktop: the workbench gives the rows the wider half and the chart the
rest, both on one height, and the configuration opens as one row of three
groups rather than a column. */
@media (width > 1024px) {
.bt-workbench {
grid-template-columns: minmax(0, 1.15fr) minmax(var(--chart-min-width), 1fr);
grid-template-rows: minmax(0, 1fr);
/* The workbench takes the page's free height, so the chart is as tall as
the viewport allows; a drag on the seam replaces that with the stored
size. */
height: var(--bt-chart-height, calc(var(--viewport-h) - var(--bt-run-chrome)));
}
/* The row owns the height, so both panes take it and scroll inside it. */
.bt-results {
height: 100%;
max-height: none;
min-height: 0;
}
.bt-chart {
height: 100%;
min-height: 0;
}
.bt-controls {
grid-template-columns: repeat(3, minmax(0, 1fr));
align-items: start;
gap: var(--space-lg);
}
.bt-controls__head {
grid-column: 1 / -1;
}
}
/* intentional breakpoint: the redesign's phone edge (600px, not the 480 phone token) */
@media (width <= 600px) {
/* One column with the results as cards. The configuration is a full-screen
sheet opened from the run bar; the run controls and the status are
pinned to the bottom of the viewport. The page reserves room for them so
the last card is never under the bar. */
.bt-layout {
padding-bottom: calc(var(--touch-min) * 2 + var(--space-lg));
}
#bt-config-toggle {
min-height: var(--touch-min);
min-width: var(--touch-min);
}
.bt-actionbar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: var(--z-5);
display: flex;
flex-direction: column;
align-items: stretch;
justify-content: flex-start;
gap: var(--space-xs);
margin-left: 0;
padding: var(--space-sm) var(--space-md) calc(var(--space-sm) + var(--safe-b));
background: var(--bg-surface);
border-top: 1px solid var(--border);
}
.bt-status {
justify-content: flex-start;
font-size: var(--font-sm);
}
.bt-actions {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: var(--space-xs);
}
.bt-actions .btn {
width: 100%;
min-height: var(--touch-min);
padding: 0 var(--space-xs);
}
/* The configuration sheet covers the page and sits above the run bar. */
.bt-controls {
position: fixed;
inset: 0;
z-index: var(--z-50);
overflow-y: auto;
/* The floating nav toggle sits in the top-left corner above the sheet, so
the sheet's own head starts clear of it. */
padding: calc(var(--nav-float-size) + var(--space-md)) var(--space-md) var(--space-md);
border: 0;
border-radius: 0;
}
.bt-controls .btn,
.bt-controls .input-field,
.bt-controls .select-field,
.bt-controls .modal-input,
.bt-controls .filter-textarea {
min-height: var(--touch-min);
}
.bt-group__fields,
.bt-group__fields--universe {
grid-template-columns: minmax(0, 1fr);
}
/* The results are cards: symbol and signal on the first line, price and time
on the second, the four volume metrics on the third. The table header is
gone, so each metric carries its own label (data-label). */
.bt-results {
max-height: none;
overflow: visible;
border: 0;
}
.bt-results-table,
.bt-results-table tbody {
display: block;
width: 100%;
}
.bt-results-table thead {
display: none;
}
.bt-sort-by {
display: flex;
align-items: center;
gap: var(--space-sm);
margin-bottom: var(--space-sm);
}
.bt-sort-by__label {
font-size: 0.8125rem;
color: var(--text-muted, inherit);
}
.bt-results-table tbody tr.bt-row {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
grid-template-areas: "sym sym sig sig" "price price time time" "dv dvp v5 v5p";
gap: var(--space-xs) var(--space-sm);
min-height: var(--touch-min);
margin-bottom: var(--space-sm);
padding: var(--space-sm) var(--space-md);
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius-xl);
}
.bt-results-table tbody tr.bt-row--active {
border-color: var(--accent);
}
.bt-results-table tbody tr.bt-row td {
display: block;
min-width: 0;
padding: 0;
border: 0;
text-align: left;
white-space: normal;
overflow-wrap: anywhere;
}
.bt-results-table tbody tr.bt-row td[data-label]::before {
content: attr(data-label);
display: block;
font-size: var(--font-xxs);
color: var(--text-muted);
text-transform: uppercase;
letter-spacing: 0.05em;
}
.bt-col--symbol {
grid-area: sym;
font-weight: 600;
}
.bt-col--signal {
grid-area: sig;
text-align: right;
}
.bt-col--price {
grid-area: price;
}
.bt-col--time {
grid-area: time;
text-align: right;
color: var(--text-muted);
}
.bt-col--dvol {
grid-area: dv;
}
.bt-col--dvol-pct {
grid-area: dvp;
}
.bt-col--v5 {
grid-area: v5;
}
.bt-col--v5-pct {
grid-area: v5p;
}
.bt-results-table .bt-empty-row,
.bt-results-table .bt-empty-row td {
display: block;
}
/* The chart is a full-screen sheet opened by a card. Close hides it again;
the card is kept, so opening another one is instant. */
.bt-chart {
display: none;
}
.bt-chart--open {
display: flex;
flex-direction: column;
position: fixed;
inset: 0;
z-index: var(--z-50);
height: auto;
padding: var(--space-sm) var(--space-sm) calc(var(--space-sm) + var(--safe-b));
background: var(--bg-surface);
}
.bt-chart__close {
display: block;
align-self: flex-end;
min-height: var(--touch-min);
margin-bottom: var(--space-xs);
}
.bt-chart--open stock-chart-card {
flex: 1 1 0;
min-height: 0;
height: auto;
}
.bt-chart--open > .panel-resize-handle--row {
display: none;
}
.backtest-tabs .btn,
[id^="backtest-tab-btn-"] {
min-height: var(--touch-min);
}
}