System Architecture =================== The FIX-FastTrade system follows a modular and extensible architecture designed for ultra-low latency trading operations. This document provides an overview of the current working implementation and its key components. Architecture Overview --------------------- The FIX-FastTrade system consists of the following main components currently implemented: 1. **FIX Service Layer**: Handles FIX protocol operations through the ``service::FixService`` class. It manages FIX sessions using the ``fix::SessionID`` implementation and processes FIX messages through the ``fix::Application`` interface. 2. **Trading Service Layer**: Manages trading operations through the ``service::TradingService`` class. It processes orders using the ``model::Order`` class and generates trades represented by the ``model::Trade`` class. 3. **FIX Protocol Infrastructure**: - **SessionID Management**: The ``fix::SessionID`` class provides flexible session identification with support for FIX version, sender, and target company IDs - **Message Handling**: The ``fix::Message`` class provides field-based message manipulation with tag-value pairs - **Zero-Copy Message Processing**: The ``fix::ZeroCopyMessage`` class enables ultra-low latency message parsing without memory allocations 4. **High-Performance Infrastructure**: - **Memory Management**: Custom memory pools in ``infrastructure/memory/`` for allocation-free operations - **Threading**: CPU affinity management in ``infrastructure/threading/CPUAffinity`` for deterministic performance - **SIMD Optimizations**: Vectorized operations in ``infrastructure/simd/SIMDUtils`` for fast message parsing - **Platform Abstraction**: Cross-platform support through ``infrastructure/platform/Platform`` 5. **Configuration Management**: XML-based configuration system with schema validation for FIX sessions and system parameters 6. **Testing Framework**: Comprehensive test suite using Google Test framework covering all major components Component Interaction --------------------- The current implementation provides the following interaction flow: 1. **Session Establishment**: The ``fix::SessionID`` class manages FIX session identification using the format "FIX_VERSION:SENDER->TARGET" (e.g., "FIX.4.4:CLIENT->SERVER") 2. **Message Processing**: - Incoming FIX messages are parsed using the ``fix::ZeroCopyMessage`` class for zero-allocation parsing - The ``fix::Message`` class provides field manipulation using integer tags from the ``fix::Tags`` namespace - Message validation occurs through the ``fix::MessageParser`` component 3. **Service Layer Processing**: - The ``service::FixService`` receives parsed messages and coordinates with the FIX application layer - The ``service::TradingService`` processes business logic for order handling and trade generation - Orders are represented by the ``model::Order`` class with full lifecycle management - Trades are created as ``model::Trade`` instances with execution details 4. **High-Performance Path**: - SIMD-optimized parsing in ``ZeroCopyMessage`` for ultra-low latency - CPU affinity management ensures deterministic thread scheduling - Memory pools eliminate allocation overhead in critical paths - Cache-aligned data structures optimize memory access patterns 5. **Configuration and Session Management**: - XML configuration files define session parameters and system settings - The ``fix::Session`` class manages connection state and message sequencing - Session recovery and persistence handled through configuration-driven mechanisms Scalability and Performance --------------------------- The current FIX-FastTrade implementation achieves ultra-low latency through several key optimizations: Zero-Copy Message Processing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * The ``fix::ZeroCopyMessage`` class eliminates memory allocations by referencing the original buffer directly * SIMD-optimized parsing using vectorized instructions for field extraction * Cache-line aligned data structures (64-byte alignment) for optimal memory access High-Performance Infrastructure ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * **CPU Affinity**: The ``infrastructure::threading::CPUAffinity`` class pins threads to specific CPU cores * **Memory Pools**: Custom allocators in ``infrastructure::memory::SimplePool`` eliminate allocation overhead * **SIMD Operations**: Vectorized string operations in ``infrastructure::simd::SIMDUtils`` for fast parsing Build Optimizations ~~~~~~~~~~~~~~~~~~~ * Aggressive compiler optimizations: ``-O3 -march=native -mtune=native -flto`` * Link-time optimization (LTO) for cross-module optimizations * Profile-guided optimization support for production workloads Scalability Features ~~~~~~~~~~~~~~~~~~~~ * **Static Library**: The ``fix-fasttrade-core`` target enables embedding in larger systems * **Modular Design**: Service layer separation allows independent scaling of components * **Configuration-Driven**: XML-based configuration enables runtime parameter tuning without recompilation Extensibility and Customization ------------------------------- The current architecture provides several extension points: Service Layer Extensions ~~~~~~~~~~~~~~~~~~~~~~~~ * The ``service::FixService`` and ``service::TradingService`` classes can be extended through inheritance * Custom order processing logic can be implemented by extending the ``model::Order`` class * Trade generation can be customized through the ``model::Trade`` interface FIX Protocol Customization ~~~~~~~~~~~~~~~~~~~~~~~~~~ * The ``fix::Tags`` namespace can be extended with custom field definitions * Message parsing can be customized through the ``fix::MessageParser`` interface * Session behavior can be modified by extending the ``fix::Session`` class Infrastructure Customization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Platform-specific optimizations can be added through the ``infrastructure::platform::Platform`` abstraction * Custom memory allocation strategies can be implemented using the memory pool interfaces * SIMD operations can be extended for specific CPU architectures Build System Integration ~~~~~~~~~~~~~~~~~~~~~~~~ * CMake targets (``fix-fasttrade`` and ``fix-fasttrade-core``) support integration into larger build systems * Dependency management through modern CMake practices enables easy third-party integration * Cross-platform support for macOS, Linux, and Windows development environments Current Build Targets --------------------- The system provides two main build targets: 1. **fix-fasttrade**: Complete executable with all components and dependencies 2. **fix-fasttrade-core**: Static library for embedding in other applications Dependencies ~~~~~~~~~~~~ * **Boost**: System, thread, filesystem, date_time, program_options, log libraries * **QuickFIX**: FIX protocol implementation (optional, can use built-in components) * **Intel TBB**: Threading Building Blocks for parallel processing (optional) * **Google Test**: Testing framework for comprehensive test coverage * **Doxygen**: API documentation generation Conclusion ---------- The current FIX-FastTrade architecture delivers a working, high-performance trading system with: * **Ultra-low latency**: Zero-copy message processing and SIMD optimizations * **Production ready**: Comprehensive testing, documentation, and build system * **Cross-platform**: Support for macOS (including ARM64), Linux, and Windows * **Extensible**: Modular design with clear interfaces for customization * **Standards compliant**: Full FIX protocol support with modern C++17 implementation The system has been successfully built and tested on macOS ARM64 systems and is ready for deployment in production trading environments.