Explore the technical architecture and implementation details of a high-performance leveraged trading engine.

Velox follows a distributed microservices architecture with six services communicating through Redis streams. Real-time price data flows from Binance via WebSocket, gets processed by the liquidation engine with in-memory state, and triggers automatic liquidations based on leverage and risk parameters. All state changes are event-sourced for crash recovery.
The engine processes orders through Redis streams with real-time price validation:
Runs on every price tick with priority-ordered triggers:
Connects to Binance for real-time trade feeds on three assets:
A market-maker spread is applied to all prices before distribution:
Dual authentication with JWT in httpOnly cookies:
Singleton for engine communication via Redis:
The system uses an async request-response pattern with Redis streams and an in-memory callback registry. This enables non-blocking communication while maintaining request-response semantics.
The engine persists full state snapshots to PostgreSQL every 15 seconds, including the last processed stream entry ID.
JavaScript Number uses IEEE 754 floating point, which introduces rounding errors in financial calculations. All prices, quantities, and margins use BigInt with 10⁸ scale factor.
Start trading with $1,000 in virtual funds on a platform built with event sourcing, in-memory state, and real-time liquidation.