This project provides a real-time financial instrument price tracking service with REST API and WebSocket capabilities. It retrieves price data from Binance and broadcasts updates to connected clients using SignalR.
- REST API: Fetch the list of available instruments and get the latest price for a specific instrument.
- WebSocket: Real-time price updates via WebSocket subscription to multiple instruments.
- Data Source: Live data from Binance's WebSocket API.
- Scalable: Designed to efficiently handle 1,000+ concurrent WebSocket subscribers.
- Backend: .NET Core, SignalR, WebSocket for real-time data
- Frontend: SignalR client for receiving updates
- External API: Binance WebSocket API for instrument prices
-
Clone the repository:
git clone https://github.com/yourusername/financial-instrument-price-service.git cd financial-instrument-price-service -
Open the solution in Visual Studio or VS Code.
-
Configure Instruments (Optional):
- Update the list of instruments in
BinanceServiceif additional instruments are needed:private readonly List<string> instruments = new List<string> { "btcusdt", "ethusdt", "bnbusdt" };
- Update the list of instruments in
-
Run the Application:
- Start the project (both client and server applications).
- The server connects to Binance’s WebSocket API and broadcasts price updates to all clients subscribed to specific instruments.
-
API Endpoints:
- GET /api/instruments: List available financial instruments.
- GET /api/instruments/{symbol}/price: Get the current price of a specific instrument.
- REST API: Use the provided endpoints to access current prices.
- WebSocket: Subscribe to live price updates through SignalR to receive price updates in real-time.
After running the application, you can:
-
Access the list of available instruments:
curl http://localhost:7075/api/instruments
-
Get the latest price for an instrument (e.g., BTCUSDT):
curl http://localhost:7075/api/instruments/btcusdt/price