Market Simulator Service
The Market Simulator Service generates synthetic trading activity — order placements, cancellations, and fills — that flows through the standard Kafka pipeline. Downstream services (Market Data, Position, Order) consume these events identically to real trading activity, making it suitable for integration testing, load testing, and running demo environments without real capital.
Responsibilities
Section titled “Responsibilities”- Synthetic Order Generation: Emit
order.command.v1events representing simulated order placements and cancellations at configurable rates and price ranges. - Price Walk: Simulate a realistic mid-price random walk within configurable bounds to produce meaningful OHLCV and order book data.
- Volume Control: Configure order size, arrival rate, and spread to match the desired market depth and activity level.
- Isolation: Operates purely through Kafka — no direct access to databases, wallets, or the matching engine’s internal state.
Architecture
Section titled “Architecture”Because the simulator emits standard Kafka events, the entire downstream pipeline — matching, market data aggregation, position tracking, and WebSocket broadcasting — behaves exactly as it would with real orders.
Language / Framework
Section titled “Language / Framework”Go
Messaging (Kafka Topics)
Section titled “Messaging (Kafka Topics)”Published
Section titled “Published”| Topic | Description |
|---|---|
order.command.v1 | Simulated order placement and cancellation commands |
Consumed
Section titled “Consumed”| Topic | Description |
|---|---|
engine.event.v1 | Fill events used to track simulated inventory and adjust quoting |
md.mark.v1 | Mark price feed used as the mid-price reference for generated quotes |
Configuration
Section titled “Configuration”| Variable | Description | Default |
|---|---|---|
KAFKA_BROKERS | Kafka broker addresses | Required |
SCHEMA_REGISTRY_URL | Confluent Schema Registry URL | Required |
SIM_SYMBOL | Instrument symbol to simulate (e.g. BTCUSDT-PERP) | Required |
SIM_ACCOUNT_ID | System account ID used for simulated orders | Required |
SIM_ORDER_RATE_MS | Interval between order submissions in milliseconds | 500 |
SIM_SPREAD_BPS | Simulated bid-ask spread in basis points | 20 |
SIM_ORDER_SIZE_USDT | Notional size per simulated order in USDT | 100 |
SIM_MAX_DEPTH | Number of price levels to maintain on each side | 10 |
SIM_PRICE_WALK_BPS | Maximum per-tick mid-price move in basis points | 5 |
SIM_BASE_PRICE | Starting mid-price (used when no mark price is available) | 50000 |
Use Cases
Section titled “Use Cases”Integration Testing
Section titled “Integration Testing”Run the simulator against a local stack to produce real Kafka traffic without manual order placement. All services respond to the synthetic events identically to production, exercising the full order → match → settle → position update path.
Load Testing
Section titled “Load Testing”Increase SIM_ORDER_RATE_MS (lower value = higher rate) and SIM_MAX_DEPTH to stress-test the matching engine throughput, Kafka consumer lag tolerance, and WebSocket broadcast latency under load.
Demo Environments
Section titled “Demo Environments”Deploy the simulator alongside a demo instance to show a live-looking order book, trade feed, and candlestick charts without requiring real users or capital.
Safety Constraints
Section titled “Safety Constraints”- ❌ Does NOT interact with real user wallets or balances
- ❌ Does NOT bypass Order Service or Matching Engine
- ❌ Does NOT read from or write to any service database directly
- ✅ All simulated orders are tagged with a designated system account ID so they are identifiable in audit logs
- ✅ Stops emitting orders immediately on shutdown (no lingering open orders in the book after restart unless the matching engine already accepted them)