https://github.com/robaho/cpp_fix_codec
ultra fast C++ FIX protocol encoder/decoder
https://github.com/robaho/cpp_fix_codec
cpp fix fix-protocol trading
Last synced: 7 months ago
JSON representation
ultra fast C++ FIX protocol encoder/decoder
- Host: GitHub
- URL: https://github.com/robaho/cpp_fix_codec
- Owner: robaho
- Created: 2025-01-15T21:43:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-25T17:05:22.000Z (over 1 year ago)
- Last Synced: 2025-01-25T18:18:22.194Z (over 1 year ago)
- Topics: cpp, fix, fix-protocol, trading
- Language: C++
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Summary
This is a C++ implementation of a FIX protocol codec.
It uses [cpp_fixed](https://github.com/robaho/cpp_fixed) to perform fixed decimal point integer math.
## Building
The project depends on the [cpp_fixed](https://github.com/robaho/cpp_fixed) project. It must be available at the
same directory level (change the `INCLUDES` entry in the `Makefile` if it is in a different location).
The project builds by default using `make` and CLang. There is a `Makefile.gcc` for building using GCC.make
## Design
The library is extremely low-level, designed for performance first. There is no automated FIX metadata. The
consumer is responsible for defining the group layout of the messages it uses.
A custom arena based memory allocator is used, and any dynamic memory is reused when parsing the next message.
Nested groups are fully supported.
## Testing
use `make run_tests` to run all of the test cases.
## Performance
Using a 4 GHz Quad-Core Intel Core i7:
The library can parse more than **2.7M messages a second** from a single istream. An istream is almost always required
because the FIX connection is over TCP and the messages are not delineated.
Parsing messages with groups slows the parsing by 10%.
After parsing, the accessing of fields is performed at more than 55M a second.
The library can encode more than 4.5M typical "new order single" messages per second. With cached time values, this
is **more than 7.5M messages per second**. Time conversion is typically slow so caching below the required accuracy is essential.
See the [benchmark parsing](https://github.com/robaho/cpp_fix_codec/blob/main/benchmark_parse_test.cpp)
See the [benchmark building](https://github.com/robaho/cpp_fix_codec/blob/main/benchmark_build_test.cpp)
performance details
New Order Single: parsed 1000000 messages, usec per order 0.368897, orders per sec 2710783
New Order Single w/Groups: parsed 1000000 messages, usec per order 0.496595, orders per sec 2013713
built 10000000 messages, usec per msg 0.223333, msgs per sec 4477614
with cached time, built 10000000 messages, usec per msg 0.133145, msgs per sec 7510597