63 lines
4.9 KiB
Markdown
63 lines
4.9 KiB
Markdown
# Stock Bot research workbench
|
|
|
|
For the complete local research stack, run `bun run infra:up` then `bun run dev:research`
|
|
from the repository root after the initial build. The API, orchestrator and browser use
|
|
ports 2003, 2004 and 5173. This preserves existing data and does not activate trading.
|
|
|
|
|
|
The React application is the primary interface for strategy versions, reproducible backtests, experiments and evidence-linked research. It consumes the TypeScript web API; the authoritative financial simulation runs in Rust behind the orchestrator.
|
|
|
|
For the whole system, start with [Understanding Stock Bot](../../../docs/guide/README.md) and the [backtest walkthrough](../../../docs/guide/backtest-walkthrough.md).
|
|
|
|
## Product areas
|
|
|
|
| Route | What is connected |
|
|
| --- | --- |
|
|
| `/strategies` | Strategy families, immutable versions, parameter forms and candidate publication/review. |
|
|
| `/backtests` | Saved configurations, retained dataset selection, durable runs, cancellation, results and reproduction. A saved run has its own reopenable URL. |
|
|
| `/experiments` | Parameter trials, comparison, chronological validation, walk-forward studies and cost sensitivity. |
|
|
| `/research` | Projects, hypotheses, findings and supporting evidence; research-agent grants and budgets have a separate page. |
|
|
| `/paper` | Human review and management of paper deployments. Creating a deployment does not activate it. |
|
|
| `/symbols`, `/exchanges` | Market catalog and symbol data views. |
|
|
| `/dashboard`, `/system/monitoring`, `/system/pipeline` | Existing overview and operational views. |
|
|
|
|
`/portfolio`, `/analytics` and `/settings` are currently placeholders. Implemented research charts and metrics live inside run and experiment views. New canonical runs currently admit one asset and one execution series; legacy results keep their qualification labels.
|
|
|
|
## Source map
|
|
|
|
| Location | Purpose |
|
|
| --- | --- |
|
|
| [src/app/App.tsx](src/app/App.tsx) | Authentication wrapper and complete route map. |
|
|
| [src/features](src/features) | Each workflow's pages, components, hooks and API functions. Start with `backtest/` to follow a run. |
|
|
| [src/components](src/components) | Shared layout, buttons, dialogs, tables and chart components. |
|
|
| [src/lib/api.ts](src/lib/api.ts) | Common API origin and cookie-authenticated request helper. |
|
|
| [src/app/AuthGate.tsx](src/app/AuthGate.tsx) | Browser authentication flow. |
|
|
|
|
The UI renders saved financial results and sends configuration changes. It does not calculate competing fill, cash or position semantics. PostgreSQL-backed API responses own run status; WebSocket updates prompt refreshes.
|
|
|
|
## Local development
|
|
|
|
Install and build the workspace from the repository root as described in the [root README](../../../README.md#build-and-verify). From this directory:
|
|
|
|
```sh
|
|
bun run dev
|
|
bun run build
|
|
bun run preview
|
|
bun run type-check
|
|
```
|
|
|
|
These start Vite development, build static assets, preview a build, and check frontend types respectively; run the command you need. React, TypeScript, Vite, Tailwind, Headless UI and Recharts are the main UI dependencies. See [package.json](package.json) for scripts and pinned ranges.
|
|
|
|
Vite is configured for `127.0.0.1:5173`, with a fixed port so it cannot silently move to an origin the API does not allow. Port `3000` belongs to Grafana in the Docker stack. Open `http://localhost:5173` or `http://127.0.0.1:5173`. The API origin is `VITE_API_BASE_URL` when supplied; the checked-in value is blank, so development follows the browser's hostname on port `2003`, and production uses the page's own origin. This keeps the session cookie on the same hostname: mixing `127.0.0.1` and `localhost` can prevent sign-in from persisting. Restart Vite after changing environment configuration. The dev server has no configured API proxy. The backend must be running and allow the frontend origin for authenticated cross-origin requests.
|
|
|
|
Browser authentication uses HttpOnly session cookies. `VITE_API_BASE_URL` is a public address, not a place for service credentials. Research runs also need the orchestrator and its configured infrastructure; starting Vite alone supplies the interface only.
|
|
|
|
## Tests and behavior
|
|
|
|
The [workbench browser test](../../../test/e2e/workbench.test.ts) exercises the authenticated API and durable workflow using disposable infrastructure. [Canonical workbench tests](../../../test/integration/canonical-workbench.test.tsx) cover retained-input configuration and results. Follow the [root test setup](../../../README.md#build-and-verify) for prerequisites rather than using a regular trading database as a test fixture.
|
|
|
|
Keep loading, empty, failed, cancelled and completed states distinct. Reopening a saved run should read the recorded result, not silently start a new simulation.
|
|
|
|
Primary navigation lists implemented workflows. Standalone Portfolio, Analytics and Settings
|
|
remain unavailable at their existing URLs and are hidden from the menu. Saved backtest and
|
|
experiment pages continue to provide performance, trade and risk analysis.
|