| .. | ||
| backtest-walkthrough.md | ||
| README.md | ||
| strategy-development.md | ||
| system-map.md | ||
Understanding Stock Bot
Start here if you want to understand the repository before changing it. These guides describe the connected implementation as of October 24, 2026, with links to the code. They cover the stock platform; apps/wcag-ada is separate.
The idea in one minute
You write a TypeScript strategy that looks at available market observations and asks for a desired position. The Rust financial engine decides whether that request is allowed, simulates execution, and updates money and positions. The web application lets you configure, run, compare and record this research.
The TypeScript backend connects those pieces. It saves exact inputs, dispatches jobs, supervises workers and records results. PostgreSQL remembers what happened; Redis delivers work. Historical prices are retained as hashed datasets so a later provider update does not silently change an old experiment.
In this repository, canonical means the supported, authoritative Rust financial path. You will also find older simulators and prototype interfaces. Their presence does not mean new web backtests use them.
Read in this order
| Guide | Question it answers |
|---|---|
| 1. System map | What are the applications, libraries and databases, and how are they connected? |
| 2. Follow one backtest | What happens between clicking Run and seeing a trade, result or failure? |
| 3. Understand and write a strategy | Where does my trading logic go, what can it access, and what does it return? |
Read the diagrams and examples first. Follow the source links when a component becomes relevant; you do not need to understand every library before writing a strategy.
A first tour through the product
When your local application is configured and running:
- Open Strategies. Inspect a strategy family and an immutable version. Notice the parameters and executable identity; editing a new version must not change old runs.
- Open Backtests. A saved backtest is a reusable configuration. Its run history contains individual executions. Select an existing run before trying to configure a new one.
- On a run, inspect its inputs, status, provenance, equity and trades. Check whether it completed and which engine/policies produced it before interpreting its metrics. Older results retain their qualifications.
- Open Experiments. These group related trials, such as a parameter sweep. Follow a trial back to its individual run; comparison is not a separate simulator.
- Open Research. A project collects hypotheses and findings linked to evidence. An AI-written hypothesis or conclusion is still a claim; the cited runs are the inspectable evidence.
With an empty database, those pages may have no saved records yet. The walkthrough and test fixture below let you understand the flow without fetching market data. Creating a run requires a retained dataset and an eligible strategy version, not just a ticker symbol.
The standalone Portfolio, Analytics and Settings routes are currently placeholders. Run and experiment pages contain the implemented research analytics. See the route map for what each URL opens.
Names you will see
| Term | Meaning here |
|---|---|
| Strategy family / version | A family organizes related revisions. A version pins a particular strategy definition and parameter contract. A run records the selected version and parameter values. |
| Backtest template | A saved configuration you can edit and use to submit runs. Editing it does not rewrite a submitted run's inputs. |
| Run / attempt | A run is one logical trial with frozen inputs. An attempt is one worker's claimed execution of it. Recovery can create another attempt without creating a different research question. |
| Retained dataset | Exact validated bars and metadata, saved under a content hash. Provider storage is the mutable source; retention supplies the research snapshot. |
| Experiment | A set of related runs with a saved comparison or search configuration. It can compare strategy candidates without combining their accounts. |
| Hypothesis / finding | The question you propose and the conclusion you record. Findings can cite exact runs and artifacts. Neither is automatically proof of a successful strategy. |
| Intent / order / fill | The strategy's desired exposure, the engine's executable instruction, and an actual simulated execution. An accepted intent is not a guaranteed fill. |
| Position / owner | A held quantity and the strategy instance responsible for it. Financial attribution uses ownership rather than assuming every trade in a symbol belongs to the same strategy. |
| Event time / availability time | When a market event happened versus when its information may be used. A completed bar cannot inform a decision before it becomes available. |
| Paper deployment | A separately reviewed, explicitly activated paper account workflow. A completed research run does not activate it. |
Learn from a small executable example
Start with the SMA fixture, then its strategy and regression tests. It uses seven bars and hand-checkable trades. The walkthrough explains why the final equity is 9969.30 from 10000 starting capital.
From the repository root, after dependencies and workspace/native builds are available:
bun test test/integration/canonical-sma.test.ts
This fixture does not need a provider connection or running databases. For initial build requirements and the broader check commands, use the root README.
What is available, and what is still constrained
- New web research runs use one execution asset and one retained series, with cash-funded, long-only financial policies. Lower-level multi-asset contracts and tests do not make multi-asset web admission available.
- TypeScript callback strategies, retained candidate packages, parameter sweeps, chronological validation, walk-forward studies and cost comparisons are connected research paths. The guides explain their boundaries rather than claiming every strategy or market model is supported.
- Research workers can execute independent trials concurrently. That does not mean multiple workers can mutate the same account simultaneously.
- Paper trading requires separate configuration, reviewed code and explicit human activation. Live trading is disabled; there is no connected real-broker execution adapter.
- A large declarative strategy language and shared feature-cache framework are not required to understand or use the current callback path.
Deeper references
- Calculation library: reviewed indicators and analytics, plus clearly separated preserved legacy functions.
- TypeScript strategy contract: the actual callback context and output types.
- Research product reference: API policies, provenance and paper setup. Its original design examples and later implementation notes need to be read in context.
- Architecture decisions: why the boundaries were chosen. These record decisions and migration context, not a substitute for the current runtime map.
- Backlog and roadmap: work history, completion evidence and conditional future tasks.
When documentation and an implementation disagree, follow the current entrypoint, contract and focused regression test. Historical plans explain the direction; these guides explain how the current pieces fit together.