A .NET 8 Web API for streaming trading events and market data to Kafka. This service enables order submission, market data publishing, and Kafka health monitoring for trading platforms.
- Submit trade orders via REST, published to Kafka
- Publish real-time market data to Kafka
- Health check endpoint for API and Kafka broker connectivity
- List Kafka topics and partition information
- .NET 8 SDK
- Kafka broker (default:
localhost:9092) - Docker (optional, for containerized deployment)
Kafka connection and producer options are set in appsettings.json under the Kafka section.
The default bootstrap server is localhost:9092.
You can adjust producer settings such as acknowledgments, idempotence, and timeouts as needed.
To run locally:
- Build the project using the .NET CLI: dotnet build
- Run the API project: dotnet run --project TradingEventsStream
To run with Docker:
- Build the Docker image: docker run -p 5000:80 -e "Kafka__BootstrapServers=host.docker.internal:9092" trading-events-stream
- POST
/api/trading/orders - Request body:
symbol,orderType,side,quantity,price,userId- Response:
orderId,status,message,timestamp
- POST
/api/trading/market-data - Request body:
symbol,bidPrice,askPrice,lastPrice,volume,bidSize,askSize- Response:
- Confirmation message
- GET
/api/trading/health - Response:
- API and Kafka connection status, timestamp, broker details
- GET
/api/trading/kafka/topics - Response:
- List of Kafka topics, partition counts, and any topic errors
- Logging is configured in
appsettings.json. - Ensure Kafka is running and accessible for local development.
- Follow project and contribution guidelines as defined in
CONTRIBUTING.mdif present.
Contributions are welcome! Please fork the repository and submit a pull request.