HighPerformanceTradingGateway is a low-latency, multithreaded C++ application designed for processing and managing fixed-income trading orders and market data using the FIX protocol. The project emphasizes high performance, modularity, and testability, making it ideal for financial trading systems.
- Order Management: Create, modify, and cancel orders with thread-safe operations
- Market Data Processing: Efficiently process real-time market data feeds
- FIX Protocol Handling: Parse and generate FIX messages with consistent field ordering
- Thread Safety: Utilizes
std::mutex
for concurrency - Testing: Comprehensive unit tests using Google Test (GTest)
- Scalable Architecture: Designed with extensibility in mind
- Client-Server Architecture: Supports multiple concurrent client connections
- Asynchronous I/O: Uses boost::asio for efficient network operations
- Message Queuing: Thread-safe message queue for order processing
- Reconnection Handling: Automatic client reconnection with configurable retry attempts
- Statistics Monitoring: Real-time server statistics including message rates and latency
HighPerformanceTradingGateway/
├── include/ # Header files
│ ├── FixMessageHandler.hpp # Handles FIX message parsing and creation
│ ├── OrderManager.hpp # Manages the lifecycle of orders
│ ├── MarketDataProcessor.hpp # Processes market data feeds
│ ├── Logger.hpp # Logging system
│ ├── MessageQueue.hpp # Thread-safe message queue
│ ├── NetworkServer.hpp # Server implementation
│ ├── NetworkClient.hpp # Client implementation
│ └── NetworkTypes.hpp # Network-related types and configs
├── src/ # Source files
│ ├── Implementation files (.cpp)
├── test/ # Test folder
│ ├── Unit tests (.cpp)
├── examples/ # Example applications
│ ├── fix_client.cpp # FIX client utility
│ ├── data/ # Sample data files
│ │ ├── sample_orders.txt # Example FIX orders
│ │ └── README.md # Data file documentation
│ └── README.md # Examples documentation
├── main.cpp # Entry point
├── CMakeLists.txt # Build configuration
└── README.md # This file
- CMake (version 3.14 or higher)
- Boost Libraries (system, thread, date_time, chrono)
- A C++ Compiler supporting C++17 (e.g., g++ or clang++)
- Google Test (GTest)
- Install dependencies (Ubuntu/Debian):
# Install build tools
sudo apt update
sudo apt install cmake build-essential
# Install Boost libraries
sudo apt install libboost-all-dev
# Install Google Test
sudo apt install libgtest-dev
- Configure and build the project:
# Configure with CMake
cmake -B build
# Build the project
cmake --build build
- Run tests:
ctest --test-dir build --output-on-failure
./build/HighPerformanceTradingGateway
The server provides real-time statistics including:
- Active connections
- Messages processed per second
- Error rates
- Average processing latency
The project includes a command-line FIX client utility with multiple operation modes:
- Interactive Mode:
./build/fix_client -i
- Single Order Mode:
./build/fix_client -o "35=D|49=SENDER|56=TARGET|11=ORDER123|55=AAPL|54=1|44=150.50|38=100|40=2|"
- Batch File Mode:
./build/fix_client -f examples/data/sample_orders.txt
The system supports standard FIX message fields:
- 35=D : New Order Single
- 49 : SenderCompID
- 56 : TargetCompID
- 11 : ClOrdID (unique order ID)
- 55 : Symbol
- 54 : Side (1=Buy, 2=Sell)
- 44 : Price
- 38 : OrderQty
- 40 : OrdType (2=Limit)
The project includes Docker support for easy deployment and testing. The Docker setup provides an isolated environment to build and run the server and client applications, ensuring compatibility across different systems.
- Docker (version 20.10 or higher)
- Docker Compose (version 1.29 or higher)
- Dockerfile: Builds the server and client applications into Docker images.
- docker-compose.yml: Manages the server and client services using Docker Compose.
- docker-run.sh: A helper script to simplify building, running, and cleaning up Docker containers.
Run the following command to build the Docker images for the project:
./docker-run.sh build
To start the server in a Docker container:
./docker-run.sh server
The server will run on port 8080 by default and provide real-time statistics about its activity.
To run the client with a default FIX order:
./docker-run.sh client
By default, the client sends the following order:
35=D|49=SENDER|56=TARGET|11=ORDER123|55=AAPL|54=1|44=150.50|38=100|40=2|
You can also pass custom arguments to the client. For example:
./docker-run.sh client -i
./docker-run.sh client -f examples/data/sample_orders.txt
To stop and remove all containers, networks, and intermediate Docker layers:
./docker-run.sh clean
The docker-compose.yml file defines the following services:
-
server: Runs the HighPerformanceTradingGateway server.
-
client: Runs the fix_client utility, which can operate in various modes (single order, batch file, or interactive).
By default, the server and client communicate over a custom Docker network (cpp-net), allowing seamless interaction between containers.
To verify that the containers are running correctly:
- Start the server:
./docker-run.sh server
- Start the client:
./docker-run.sh client
The client should connect to the server and process messages without errors.
The project includes comprehensive test suites:
# Run all tests
ctest --test-dir build --output-on-failure V
# Run specific test suite
./build/HighPerformanceTradingGatewayTests
The examples/
directory contains sample applications and data files demonstrating the gateway's functionality. See examples/README.md for detailed information.
- SSL/TLS support for secure connections
- Market data feed integration
- Order book management
- Risk management system
- Performance monitoring and metrics
- WebSocket interface for real-time updates