This project implements an in-memory order book for placing limit orders with order matching capabilities. It provides APIs to view the order book, submit limit orders, and view recent trades.
- Get Order Book: View the current state of the order book with aggregated bids and asks.
- Submit Limit Order: Place buy or sell limit orders with automatic matching.
- Recent Trades: Retrieve a list of recent trades executed in the order book.
- Kotlin
- Vert.x
- Jackson
- JUnit 5
- Maven
- Get Order Book
- Endpoint:
/orderbook
- Method: GET
- Headers: Authorization: Your api key
- Endpoint:
Response:
{
"asks": [],
"bids": []
}
- Submit Limit Order
- Endpoint:
/orders/limit
- Method: POST
- Headers: Authorization: Your api key
- Request Body:
{ "side": "BUY or SELL", "price": "Order price", "quantity": "Order quantity", "currencyPair": "BTCZAR" }
- Endpoint:
Response:
{
"message": "Order placed successfully"
}
- Recent Trades
- Endpoint:
/trades/recent
- Headers: Authorization: Your api key
- Method: GET
- Endpoint:
Response:
[
{
"price": "1200000",
"quantity": "0.05",
"currencyPair": "BTCZAR",
"tradedAt": "2024-10-15T17:52:11.342Z",
"takerSide": "sell",
"sequenceId": 1295806444729278500,
"id": "343c6e02-8b1e-11ef-b601-d1eca0747ffd",
"quoteVolume": "60000.00"
}
]
- The API uses a simple API key for authentication. run a uuidgen and update secret to the application.conf
-
Build the Project:
gradle wrapper ./gradlew build
-
Run the Application:
./gradlew run
-
Run Tests:
./gradlew test
Anjolaiya Oladapo