{"id":22209390,"url":"https://github.com/jialuechen/thunderfix","last_synced_at":"2025-03-15T09:07:50.513Z","repository":{"id":225753067,"uuid":"766697276","full_name":"jialuechen/thunderfix","owner":"jialuechen","description":"Super Fast FIX Protocol C++ Library","archived":false,"fork":false,"pushed_at":"2024-10-29T01:55:48.000Z","size":2064,"stargazers_count":102,"open_issues_count":0,"forks_count":15,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-06T08:12:19.414Z","etag":null,"topics":["asio","cpp","deserialization","financial-information-exchange","high-frequency-trading","json","market-making","parser","quantitative-trading","serialization","strategy-development"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jialuechen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-04T00:07:26.000Z","updated_at":"2025-03-05T05:08:42.000Z","dependencies_parsed_at":"2024-07-16T18:46:35.945Z","dependency_job_id":"c4367c2c-9c7d-4c40-b8d9-610b5a132300","html_url":"https://github.com/jialuechen/thunderfix","commit_stats":null,"previous_names":["jialuechen/llmbroker","jialuechen/statsmaker","jialuechen/thunderfix"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jialuechen%2Fthunderfix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jialuechen%2Fthunderfix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jialuechen%2Fthunderfix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jialuechen%2Fthunderfix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jialuechen","download_url":"https://codeload.github.com/jialuechen/thunderfix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243707371,"owners_count":20334618,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asio","cpp","deserialization","financial-information-exchange","high-frequency-trading","json","market-making","parser","quantitative-trading","serialization","strategy-development"],"created_at":"2024-12-02T19:30:04.701Z","updated_at":"2025-03-15T09:07:50.486Z","avatar_url":"https://github.com/jialuechen.png","language":"C++","readme":"# ThunderFix\n\n**ThunderFix** is a high-performance, low-latency C++ FIX protocol library designed for high-frequency trading, real-time market data parsing, and order management in financial systems. This library provides a modular design with support for risk management, load balancing, logging, message replay, dynamic resource management, and other advanced features, making it ideal for demanding high-load environments.\n\n## Features\n\n1. **Multi-Version Support**: Supports different versions of the FIX protocol (e.g., 4.0, 4.2, 4.4) to accommodate diverse requirements.\n2. **Low-Latency Design**: Utilizes `asio` for asynchronous I/O, optimized memory management for efficient message processing.\n3. **Modular Structure**: Core and extension modules are separated for ease of maintenance and expandability.\n4. **Advanced Risk Management**: Includes multi-level risk controls, such as order limits, daily position limits, and loss limits.\n5. **Dynamic Load Management**: Multi-session support and load balancing module for efficient resource allocation.\n6. **Logging and Auditing**: Supports dynamic logging levels with latency monitoring and audit logs to meet compliance requirements.\n7. **Data Compression**: Compression module for low-bandwidth environments.\n8. **Message Replay and Recovery**: Ensures message integrity with message replay in cases of disconnection or message loss.\n9. **Configuration Management**: Configuration file to define risk control, logging, networking parameters, and more.\n\n## Getting Started\n\n### 1. Prerequisites\n\n- C++17 or higher\n- [Asio](https://think-async.com/Asio/) - Asynchronous networking library\n- [JsonCpp](https://github.com/open-source-parsers/jsoncpp) - JSON parsing library\n\n### 2. Build Instructions\n\nIn the project root directory, execute the following commands to build the project:\n\n```bash\nmkdir build\ncd build\ncmake ..\nmake\n```\n\n### 3. Running Examples\n\nAfter building the project, you can run the examples found in the `examples` folder:\n\n```bash\n# Basic usage example\n./BasicUsageExample\n\n# Advanced usage example with risk control, load balancing, heartbeat, etc.\n./AdvancedUsageExample\n```\n\n## Usage Guide\n\n### Configuration File (`config/config.json`)\n\nThe `config.json` file defines settings for risk management, logging, network connections, rate limiting, and more:\n\n```json\n{\n    \"risk\": {\n        \"maxOrderAmount\": 1000000,\n        \"maxPosition\": 5000000,\n        \"maxDailyLoss\": 50000\n    },\n    \"logging\": {\n        \"level\": 2  // 0=INFO, 1=WARNING, 2=ERROR, 3=DEBUG\n    },\n    \"connection\": {\n        \"host\": \"example.fixserver.com\",\n        \"port\": \"5000\",\n        \"heartbeatInterval\": 30\n    },\n    \"rateLimiter\": {\n        \"maxOrdersPerMinute\": 60\n    }\n}\n```\n\n- **risk**: Risk parameters, including order size limits, position limits, and daily loss limit.\n- **logging**: Logging settings, defining the output log level.\n- **connection**: Network parameters, including server address, port, and heartbeat interval.\n- **rateLimiter**: Rate limiting, defining the maximum number of orders allowed per minute.\n\n### Module Descriptions\n\n#### Core Modules\n\n- **FIXParser**: Parses and builds FIX messages, extracting fields and verifying format.\n- **FIXSession**: Manages session state, sequencing, and heartbeat, handling message reception and transmission.\n- **FIXConnection**: Responsible for asynchronous communication with the server.\n- **Logger**: Dynamic logging with support for performance monitoring.\n- **ConfigurationLoader**: Loads the `config.json` configuration file and applies settings to modules.\n\n#### Extension Modules\n\n- **RiskControl**: Ensures trades comply with preset risk limits.\n- **LoadBalancer**: Load balancing across sessions, dynamically choosing the best connection based on latency.\n- **OrderRateLimiter**: Limits order submission rate to avoid exceeding frequency limits.\n- **MessageReplay**: Message replay for session disconnection and message loss.\n- **AuditLog**: Records all significant events and trade information for auditing purposes.\n\n### Example Code\n\nBelow is a basic usage example showing how to use the library to parse messages, establish connections, and perform simple risk control.\n\n#### Example: `examples/BasicUsageExample.cpp`\n\n```cpp\n#include \"ThunderFix.h\"\n#include \u003ciostream\u003e\n\nint main() {\n    // Initialize configuration and session\n    ConfigurationLoader configLoader;\n    configLoader.loadConfig(\"config/config.json\");\n\n    FIXSession session(FIXVersion::FIX_4_2, asio::io_context());\n    session.start();\n\n    // Parse a message\n    FIXParser parser(FIXVersion::FIX_4_2);\n    parser.parseMessage(\"8=FIX.4.2|35=D|55=AAPL|54=1|38=100|\");\n\n    // Extract fields\n    std::string symbol = parser.getField(\"55\").data();\n    int side = std::stoi(parser.getField(\"54\").data());\n\n    Logger::log(LogLevel::INFO, \"Parsed Symbol: \" + symbol);\n    Logger::log(LogLevel::INFO, \"Parsed Side: \" + std::to_string(side));\n\n    return 0;\n}\n```\n\n#### Example: `examples/AdvancedUsageExample.cpp`\n\n```cpp\n#include \"ThunderFix.h\"\n#include \u003ciostream\u003e\n\nint main() {\n    // Load configuration\n    ConfigurationLoader configLoader;\n    configLoader.loadConfig(\"config/config.json\");\n\n    asio::io_context ioContext;\n    FIXSession session(FIXVersion::FIX_4_2, ioContext);\n    session.start();\n\n    // Set up risk control\n    RiskControl riskControl;\n    if (!riskControl.checkOrderLimits(150000)) {\n        Logger::log(LogLevel::WARNING, \"Order amount exceeds limit.\");\n    }\n\n    // Rate limiter example\n    OrderRateLimiter rateLimiter(60);\n    if (rateLimiter.canSendOrder()) {\n        Logger::log(LogLevel::INFO, \"Order allowed.\");\n    } else {\n        Logger::log(LogLevel::WARNING, \"Order rate limit exceeded.\");\n    }\n\n    ioContext.run();\n    return 0;\n}\n```\n\n## Testing\n\nThe `tests` directory contains unit tests for each core and extension module. The tests use the [Google Test (gtest)](https://github.com/google/googletest) framework to ensure reliability.\n\nTo run the tests:\n\n```bash\n# Run in the build directory\nmake test\n```\n\n### Test Coverage\n\n- **FIXParserTest.cpp**: Tests FIX message parsing and field extraction.\n- **FIXSessionTest.cpp**: Tests session management, sequencing, and heartbeat.\n\n## Deployment and Customization\n\nTo deploy ThunderFix in a production environment, customize the configuration file (`config.json`) to match specific operational requirements. The configuration file allows for easy tuning of risk limits, logging levels, connection settings, and more.\n\n## Future Enhancements\n\nPotential future extensions to this library include:\n\n1. **Smart Order Routing**: Implement order routing strategies based on market conditions, liquidity, and execution efficiency.\n2. **Integration with Trading Algorithms**: Support trading strategies such as VWAP and TWAP, integrated directly within the FIX sessions.\n3. **Distributed Architecture**: Enable distributed session management across nodes for scalability in ultra-high-frequency environments.\n4. **Enhanced Risk Management**: Dynamic risk controls based on market volatility and significant events.\n\n---\n\n## License\n\nThis project is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Contributing\n\nContributions are welcome! Please submit issues, fork the repository, and create pull requests. For significant changes, please discuss with the repository maintainers beforehand to ensure alignment with the project goals.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjialuechen%2Fthunderfix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjialuechen%2Fthunderfix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjialuechen%2Fthunderfix/lists"}