From 8587c71cf381595bf99de1866cbd29660054c57c Mon Sep 17 00:00:00 2001 From: Boki Date: Sat, 24 Oct 2026 18:59:32 -0400 Subject: [PATCH] docs: align stock readmes with current research platform --- apps/stock/README.md | 165 ++++++---------------- apps/stock/TRADING_SYSTEM_README.md | 5 + apps/stock/web-app/README.md | 107 +++++--------- docs/development/architecture/overview.md | 4 + 4 files changed, 83 insertions(+), 198 deletions(-) diff --git a/apps/stock/README.md b/apps/stock/README.md index a82978b0..dfac2f6e 100644 --- a/apps/stock/README.md +++ b/apps/stock/README.md @@ -1,124 +1,41 @@ -# Stock Trading Bot Application - -A comprehensive stock trading bot application with multiple microservices for data ingestion, processing, and API access. - -## Architecture - -The stock bot consists of the following services: - -- **Config**: Centralized configuration management -- **Data Ingestion**: Handles real-time and historical data collection -- **Data Pipeline**: Processes and transforms market data -- **Web API**: RESTful API for accessing stock data -- **Web App**: Frontend user interface - -## Quick Start - -### Prerequisites - -- Node.js >= 18.0.0 -- Bun >= 1.1.0 -- Turbo -- PostgreSQL, MongoDB, QuestDB, and Redis/Dragonfly running locally - -### Installation - -```bash -# Install all dependencies -bun install - -# Build the configuration package first -bun run build:config -``` - -### Development - -```bash -# Run all services in development mode (using Turbo) -bun run dev - -# Run only backend services -bun run dev:backend - -# Run only frontend -bun run dev:frontend - -# Run specific service -bun run dev:ingestion -bun run dev:pipeline -bun run dev:api -bun run dev:web -``` - -### Production - -```bash -# Build all services (using Turbo) -bun run build - -# Start with PM2 -bun run pm2:start - -# Check status -bun run pm2:status - -# View logs -bun run pm2:logs -``` - -### Configuration - -Configuration is managed centrally in the `config` package. - -- Default config: `config/config/default.json` -- Environment-specific: `config/config/[environment].json` -- Environment variables: Can override any config value - -### Health Checks - -```bash -# Check all services health -bun run health:check -``` - -### Database Management - -```bash -# Run migrations -bun run db:migrate - -# Seed database -bun run db:seed -``` - -## Available Scripts - -| Script | Description | -|--------|-------------| -| `dev` | Run all services in development mode | -| `build` | Build all services | -| `start` | Start all backend services | -| `test` | Run tests for all services | -| `lint` | Lint all services | -| `clean` | Clean build artifacts and dependencies | -| `docker:build` | Build Docker images | -| `pm2:start` | Start services with PM2 | -| `health:check` | Check health of all services | - -## Service Ports - -- Data Ingestion: 2001 -- Data Pipeline: 2002 -- Web API: 2003 -- Web App: 3000 (or next available) - -## Environment Variables - -Key environment variables: - -- `NODE_ENV`: development, test, or production -- `PORT`: Override default service port -- Database connection strings -- API keys for data providers - -See `config/config/default.json` for full configuration options. \ No newline at end of file +# Stock platform + +The stock application combines a TypeScript research workbench and strategy runtime with an authoritative Rust financial engine. + +**Start with [Understanding Stock Bot](../../docs/guide/README.md).** It explains the connected system, follows a complete backtest, and introduces the actual strategy API. + +## Applications + +| Folder | Responsibility | +| --- | --- | +| [web-app](web-app/README.md) | React interface for strategies, backtests, experiments, research and paper deployment review. | +| [web-api](web-api/src/index.ts) | Research APIs, database migrations, durable submission and dispatch, result retrieval and WebSocket updates. | +| [orchestrator](orchestrator/src/index.ts) | Durable research workers and explicitly configured paper execution. | +| [engine](engine/src/financial) | Native Rust replay, matching, risk, ledger and financial reports. Loaded by Bun; it is not a separate HTTP service. | +| [data-ingestion](data-ingestion/src/index.ts) | Provider integration and raw data collection. | +| [data-pipeline](data-pipeline/src/index.ts) | Provider exchange/symbol metadata normalization and catalog synchronization. | +| [config](config/src/index.ts) | Stock-specific configuration and shared application contracts. | + +The [system map](../../docs/guide/system-map.md) explains their databases, queues, shared libraries and process boundaries. Replay of retained historical input does not need another provider fetch. Service startup still needs the stores enabled by its configuration and dependency container. + +## Build and development + +Run the repository-wide install, build and checks from the **repository root**, following the [root README](../../README.md#build-and-verify). That build includes shared libraries and the native engine. + +After the required local services and configuration are ready, individual development entrypoints are: + +```sh +bun run --cwd apps/stock/web-app dev +bun run --cwd apps/stock/web-api dev +bun run --cwd apps/stock/orchestrator dev +``` + +Run these in separate terminals from the repository root. The frontend alone does not run backtests; the API and orchestrator handle admission and execution. Ingestion and pipeline are additional entrypoints when you need to collect source data or synchronize the catalog. + +Stock configuration is loaded by [config-instance.ts](config/src/config-instance.ts), with stock-specific validation in [stock-app.schema.ts](config/src/schemas/stock-app.schema.ts). HTTP authentication/session behavior is in the shared [security module](../../libs/core/di/src/http/security.ts). Keep backend credentials out of frontend build variables. + +## Supported execution + +Current web research uses retained strategy versions and datasets, one execution asset/series, cash-funded long-only accounting, and the canonical Rust engine. Research candidates execute in isolation. Paper execution requires separate review, configuration and activation; live broker execution is disabled. + +[TRADING_SYSTEM_README.md](TRADING_SYSTEM_README.md) preserves an earlier design. Its proposed interfaces, performance descriptions and live-trading claims do not describe the current connected runtime. diff --git a/apps/stock/TRADING_SYSTEM_README.md b/apps/stock/TRADING_SYSTEM_README.md index cfd4dfd3..6aae399e 100644 --- a/apps/stock/TRADING_SYSTEM_README.md +++ b/apps/stock/TRADING_SYSTEM_README.md @@ -1,5 +1,10 @@ # Unified Trading System Architecture +> **Historical design reference.** This document preserves an earlier architecture proposal. +> Its illustrative APIs, latency claims, Python role and live-broker descriptions are not +> evidence of the current runtime. Read the [current project guide](../../docs/guide/README.md) +> for implemented components, execution boundaries and supported workflows. + A high-performance trading system that seamlessly handles backtesting, paper trading, and live trading using a three-tier architecture optimized for different performance requirements. ## Architecture Overview diff --git a/apps/stock/web-app/README.md b/apps/stock/web-app/README.md index 841e05f9..8fab6a22 100644 --- a/apps/stock/web-app/README.md +++ b/apps/stock/web-app/README.md @@ -1,95 +1,54 @@ -# Stock Bot Web Dashboard +# Stock Bot research workbench -A modern React web dashboard for the Stock Bot trading system. +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. -## Features +For the whole system, start with [Understanding Stock Bot](../../../docs/guide/README.md) and the [backtest walkthrough](../../../docs/guide/backtest-walkthrough.md). -- **Modern UI**: Built with React 18 and TypeScript -- **Tailwind CSS**: For beautiful, responsive styling -- **Headless UI**: Accessible components for dialogs and interactions -- **Heroicons**: Beautiful SVG icons -- **Responsive Design**: Works on desktop and mobile -- **Side Navigation**: Clean navigation with mobile-responsive sidebar +## Product areas -## Tech Stack +| 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. | -- **React 18** with TypeScript -- **Vite** for fast development and building -- **Tailwind CSS** for styling -- **Headless UI** for accessible components -- **Heroicons** for icons -- **Bun** for package management +`/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. -## Getting Started +## Source map -### Prerequisites +| 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. | -- Bun (for package management) -- Node.js 18+ +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. -### Installation +## Local development -```bash -# Install dependencies -bun install +Install and build the workspace from the repository root as described in the [root README](../../../README.md#build-and-verify). From this directory: -# Start development server +```sh bun run dev - -# Build for production bun run build - -# Preview production build bun run preview +bun run type-check ``` -## Available Scripts +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. -- `bun run dev` - Start development server -- `bun run build` - Build for production -- `bun run preview` - Preview production build -- `bun run lint` - Run ESLint -- `bun run type-check` - Run TypeScript type checking +Vite is configured for `127.0.0.1:3000`. The API origin is `VITE_API_BASE_URL` when supplied; otherwise development uses the browser's hostname on port `2003`, and production uses the page's own origin. The dev server has no configured API proxy. The backend must be running and allow the frontend origin for authenticated cross-origin requests. -## Project Structure +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. -``` -src/ -├── App.tsx # Main app component with sidebar navigation -├── main.tsx # React app entry point -└── index.css # Global styles with Tailwind directives -``` +## Tests and behavior -## Dashboard Features +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. -The dashboard includes: - -- **Responsive Sidebar**: Navigation that works on desktop and mobile -- **Dashboard Overview**: Portfolio value, returns, and active strategies -- **Navigation Sections**: - - Dashboard (current page) - - Portfolio - - Analytics - - Reports - - Settings - -## Development - -The app is set up with: - -- TypeScript for type safety -- ESLint for code quality -- Tailwind CSS for utility-first styling -- Headless UI for accessible components -- Hot module replacement for fast development - -## Integration - -This web app is part of the larger Stock Bot system and will integrate with: - -- Data Service (for market data) -- Portfolio Service (for portfolio management) -- Strategy Service (for trading strategies) -- Execution Service (for trade execution) - -The web dashboard will communicate with these services via REST APIs to provide a complete trading dashboard experience. +Keep loading, empty, failed, cancelled and completed states distinct. Reopening a saved run should read the recorded result, not silently start a new simulation. diff --git a/docs/development/architecture/overview.md b/docs/development/architecture/overview.md index 23accf01..eee65150 100644 --- a/docs/development/architecture/overview.md +++ b/docs/development/architecture/overview.md @@ -1,5 +1,9 @@ # Architecture baseline and target +> **Historical planning baseline.** The observations and example interfaces below describe +> the pre-migration state and proposed design, not today's runtime. For the implemented +> connections and current strategy API, start with the [project guide](../../guide/README.md). + Planning baseline: commit `b7aeca4`, inspected 2026-10-22. This is a proposed plan, not an implementation or project correctness-gate evidence. [Decisions](../backlog/manifest.json) and [verified findings](../backlog/findings.md) distinguish user mandates, proposed policies and uncertainties. ## What exists