# Stock platform 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 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. Open `http://localhost:5173` and sign in with `STOCK_BOT_ADMIN_TOKEN` from the root `.env`. Both `STOCK_BOT_ADMIN_TOKEN` and `STOCK_BOT_SERVICE_TOKEN` must be configured as distinct values of at least 32 characters before starting HTTP services. The API uses port `2003`; the orchestrator uses `2004`. The frontend has a fixed port to avoid colliding with Docker's Grafana (`3000`) and Bull Board (`3001`) or silently moving to an unapproved browser origin. 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.