Team Members: Tani Diament, Shimmie Hahn, Yisroel Newmark, Matias Salem
A distributed market maker that consumes exchange data and publishes quotes in real time, executing trades against them across a fault-tolerant cluster.
What makes the system interesting:
- 14-node K3s cluster (3 control plane nodes + 11 worker nodes) running 7 market-maker pods and three replicated upstream services (Exchange, Trading State, Exposure Reservation) each as 1 leader + 2 hot-backup replicas.
- Durable in-memory state — every IMap (
positions,fills,quotes,reservations,external-orders) is write-through via a JPAMapStoreto a single PostgreSQL StatefulSet, withInitialLoadMode = EAGERso a full cluster restart rebuilds state with no operator intervention. - ZooKeeper-coordinated failover — Curator
LeaderLatchelects the writable replica per service; clients resolve the current leader via an ephemeral/mm/endpoints/{svc}znode, so failover is invisible to callers.
The full stack — 3× Zookeeper, Postgres, 3× Trading State, 3× Exchange, 3× Exposure Reservation, 7× Market Maker, Position UI, external publisher, nginx LB — runs locally via compose.yml.
mvn -DskipTests clean package
docker build -t market-maker .
docker compose upOnce everything reports healthy:
- Position UI — http://localhost:18080
- External publisher — http://localhost:18083
- Market Maker nodes — http://localhost:8081 … http://localhost:8087
For the production K3s deployment (air-gapped image bundling, ZK quorum, Headlamp, integration tests), see docs/installation.md.
src/main/java/edu/yu/velocitytrading/
├── exchange/ # Order matching, fill emission (REST + RSocket)
├── state/ # TradingStateService — positions/fills owner; state.stream
├── exposurereservation/ # Global exposure budget; reservation lifecycle
├── marketmaker/ # MM node: quote generation, freshness, position tracking
├── cluster/ # Coordinator, symbol-shard assignment, Zk-watched listeners
├── ha/ # LeaderLatch, LeaderGuardFilter, LeaderAwareRSocketClient
├── persistence/ # JPA entities + Hazelcast MapStores
├── memory/ # HazelcastRepository wrapper around IMap
└── model/ # Records: Position, Fill, Quote, Reservation, StateSnapshot
docs/ # design docs (see index below)
k8s/ # Kustomize manifests for the 14-node K3s deploy
scripts/ # PowerShell + bash helpers (image bundling, SSH setup, …)
compose.yml # Local Docker Compose equivalent of the cluster
