This application is designed to function as a real-time data aggregator and trading system, capable of collecting, processing, and distributing market data to facilitate automated trading decisions. It integrates multiple protocols such as FIX, WebSocket, and REST APIs to manage real-time data streams, execute trades, and provide analytics. This system is ideal for use in financial markets where low latency and high concurrency are critical.
- Real-Time Market Data Aggregation: The application collects live market data using WebSocket and REST APIs, aggregates it, and makes it available for trading algorithms.
- Automated Trading: The FIX protocol is used for executing trades based on real-time data processed by the system.
- Market Depth Analysis: Fetches order book data to provide insights into market liquidity and potential price movements.
- Endpoint: http://127.0.0.1:8080/stocks
- Method: GET
- Query Parameters (all optional):
- symbol: Filter by symbol (e.g., AAPL).
- exchange: Filter by exchange name (e.g., NASDAQ).
- mic_code: Filter by market identifier code (MIC) (e.g., XNAS).
- country: Filter by country (e.g., United States).
- type_: Filter by instrument type (e.g., Common Stock).
- Example curl Command:
- Example Response:
- [ { "symbol": "AAPL", "name": "Apple Inc", "currency": "USD", "exchange": "NASDAQ", "mic_code": "XNAS", "country": "United States", "type_": "Common Stock" } ]
- Rust : Ensure that Rust is installed on your machine. You can install Rust by following the instructions at rust-lang.org.
- Cargo : Rust’s package manager, cargo, will be used to build and run the application.
git clone https://github.com/your-repo/trading-system.git
cd trading-system
Create a .env file in the root of the project and add the following:
API_KEY=your_twelve_data_api_key FIX_SERVER_ADDRESS=127.0.0.1 FIX_SERVER_PORT=12345 cargo build --release cargo run --releaseThe server will start and listen on http://127.0.0.1:8080.
Used in WebSocket handling via the actix framework, where each WebSocket connection is managed as an actor.
Employed in creating and managing instances of clients like the TwelveDataAPI and FixSession.
The broadcast channel in WebSocket and FIX sessions implements an observer pattern where multiple subscribers can receive updates.
WebSocket
Purpose: WebSockets provide full-duplex communication channels over a single TCP connection. In this application, WebSockets are used to receive real-time updates from market data providers and push them to connected clients.
FIX (Financial Information eXchange)Purpose: FIX is a standardized protocol used for real-time electronic communication of financial transactions. The application uses FIX for executing trades and managing orders.
RESTPurpose: REST (Representational State Transfer) is an architectural style for designing networked applications. It uses HTTP requests to access and manipulate data.