Concurrency2025

Stock Market Simulator

Multithreaded Java limit-order-book simulator with a price-time matching engine.

Trader threads place market and limit orders against independent per-symbol order books. A matching engine enforces price-time priority, executes crossing orders at the resting order’s limit price, re-rests unfilled remainder, and tracks position and PnL — all while a price engine walks each symbol under a Gaussian random walk and a JavaFX dashboard renders it live.

ContributionWhole system: order books, matching engine, price engine, threading model and dashboard.

40,000+Concurrent trades handledStated on CV; the repository configures 4 trader threads at 5 ticks/sec.
5/secPrice ticks
4Trader threads
3Symbols
100,000Starting cash per trader

How it works

  • Order book implements price-time priority with two priority queues and explicit comparators.
  • Matching engine executes crossing limit orders at the resting order’s limit price and re-rests the remainder.
  • Price engine applies a geometric random walk per tick (≈0.1% standard deviation) at 5 ticks per second.
  • Concurrency via java.util.concurrent with a ScheduledExecutorService driving ticks.
  • Live JavaFX dashboard renders books, fills and PnL as the simulation runs.
  • Pluggable trader strategies, each running on its own thread.
Stock Market Simulator — Alejandro Newport