Algo Trade Simulator

Lets strategies face real market data without letting simulated capital pretend to be real.

operational overview

ATS exists to research strategies without risking capital: stream the real market, trade a simulated book. The FastAPI backend owns market data, strategy training, accounts, and simulations; the React + Vite frontend surfaces live charts, portfolio state, and trained strategies.

architecture

Live quotes, charts, and intraday stats stream from Yahoo Finance for any searchable ticker. The strategy engine trains an SMA crossover on five years of historical data and serves live signals against the latest market regime. Accounts, sessions, and simulations persist in MongoDB through Motor (async), with an in-memory store available for quick local runs. A hybrid chatbot copilot — OpenAI chat completions with heuristic fallbacks — answers research questions and creates simulations from prompts like 'create a simulation for AAPL with 25k'. Sessions restore from browser storage.

FEEDQUOTESSTRATEGYSIGNALLEDGERCOPILOTINREC

constraints

  • market data dependency — the platform is downstream of a public quote API it does not control
  • simulation honesty — signals come from the live regime, but execution stays simulated; the boundary is structural
  • natural-language commands — the copilot must produce valid simulations from loose prompts or decline

tradeoffs

  • a hybrid copilot (LLM + heuristic fallbacks) over LLM-only: deterministic parsers carry simulation creation after model-only extraction produced malformed simulations from loose prompts
  • an in-memory store option over Mongo-always: zero-setup local runs at the cost of persistence
  • one strategy family first (SMA crossover) over a strategy zoo: a complete train→signal→simulate loop before breadth

failure notes

  • the copilot ships with configurable model fallbacks and heuristic paths — the design assumes the LLM route fails and routes around it
  • the in-memory fallback exists because database connectivity is a real failure mode, not a hypothetical

infrastructure

fastapi · react + vite + typescript · mongodb (motor) · yahoo finance api · openai api

engineering reasoning

Trading systems make probabilistic reasoning concrete: a strategy's edge either survives the live regime or it doesn't, and a simulated ledger makes being wrong cheap and visible. Keeping data, strategy, and persistence as separate services means each can fail — and be observed failing — independently.

future work

  • additional strategy families beyond SMA crossover
  • richer execution modeling (slippage, latency) on the simulated book