This is an implementation of an order book with a simple UI and WebSocket-based real-time updates. This is a microservice architecture app.
- FastAPI backend with WebSocket support
- Redis-based order book implementation
- Real-time order book updates
- Order placement, modification, and cancellation
- Trade matching engine
- WebSocket-based client communication
POST /place: Place a new orderPOST /modify: Modify an existing orderPOST /cancel: Cancel an existing orderPOST /fetch: Fetch details of a specific orderGET /orders: Get all ordersGET /trades: Get all trades
/ws/order_book: Real-time order book updates/ws/{client_id}: Client-specific WebSocket connection
- Install dependencies (FastAPI, Redis, etc.)
- Set up a Redis server
- Configure Redis connection in the environment variables:
REDIS_HOST(default: "localhost")REDIS_PORT(default: 6379)
docker-compose up --build
The server will start on http://0.0.0.0:8000.
A simple HTML/JavaScript frontend is provided in the static directory.
This project is a basic implementation and may require additional security measures and optimizations for production use.