Skip to content

Prayog

A simulated stock exchange and bot arena. Simulated traders create the market; people trade on it by hand in the browser or with their own bots, against a real matching engine with a journal and deterministic replay.

  • Visit the market

    Watch the live order book and trades, sign in, place and cancel orders.

    Using the market

  • Build a bot

    Get a token, read the feeds, send orders with the Python SDK.

    Bot builder guide · API

  • Run & debug

    Start the stack, check its health, break it on purpose, find out why.

    Runbook

  • Learn how it works

    Session notes, decisions and 15 interactive explainers with simulators.

    Learnings · Interactive pages

How it fits together

Click any box to read the page that explains it.

Using the market Browser web market page Bot builder guide Your bot Python SDK Market making (interactive) Simulated traders market maker, noise Compose and Traefik (interactive) Traefik reverse proxy, *.prayog.localhost OAuth2 and OIDC (interactive) Keycloak sign-in, JWT Technical overview (interactive) Exchange service · one JVM, one shard ↗ JWT keys direct, inside Docker S10 to S13: the live market Gateway REST + WebSocket, JWT, rate limits Ring buffer (interactive) Ring buffer LMAX Disruptor, one sequence S3 to S4: contracts and the order book Matching engine single writer, price-time priority Journaling (interactive) Journal write-ahead, fsync per batch outbound Market data feeds (interactive) Market data snapshot + deltas ADR 0009: gateway, market data and recovery Private feed your orders, fills to browsers and bots over WebSocket S7: sequencer pipeline and simulated clock Clock time is an input SBE (interactive) SBE codec binary records S8: journal and deterministic replay Replay same bytes out ADR 0015: post-trade ledger and leaderboard After the trade · post-trade service ↗ journaled events Kafka (interactive) Kafka event stream S2: local infrastructure PostgreSQL ledger, P&L Runbook: data and messaging Redis leaderboard

Learning path

The project in the order it was built. Each step has session notes (concepts to tick off, explain-back answers) and, where one exists, an interactive page with a simulator.

Background: industry context (exchange vs trading firm, what production engines do differently). Every decision: Decisions. What's done and next: Progress.

Run it locally

You need Java 21, Docker (Desktop with at least 4 GB of memory), uv, and Node 22 with pnpm 10 (corepack).

make env    # once: creates .env with random local secrets (git-ignored)
make up     # builds and starts everything; add PROFILES="infra app obs" for Prometheus and Grafana
make smoke  # quick checks
make e2e    # the live market is correct: feeds, liquidity, bots, Kafka outage, post-trade, journal replay
make down   # stops it (data is kept); `make reset` also deletes the data volumes
make test   # build and test everything
Address What
http://app.prayog.localhost The live market: watch without signing in; sign in as trader1 to trade, ops1 for the ops page
http://api.prayog.localhost The exchange and post-trade API for bots (reference)
http://grafana.prayog.localhost Dashboards (profile obs)
http://auth.prayog.localhost Keycloak; admin console at /admin (credentials in .env)
http://traefik.prayog.localhost/dashboard/ Traefik routes

Step-by-step checks, failure drills and debugging help are in the runbook; start with Start and stop.