FIX stands for Financial Information eXchange protocol.
fixparser is a single header library that helps parsing a FIX message, and translate it into a human readable way. It can also be used to check if a FIX message/response is valid. The supported protocol version is FIX.4.4. Check the spec
folder to see all the available versions.
- CMAKE 3.10 or greater
- Clang or G++ 8.3.0 (That supports C++17)
- Conan - C/C++ package manager
If you're not using Conan you'll need to install PugiXml and make it globally available.
After all the requirements have been met, you can proceed to the "out of source" building
Running these commands successively you will have the library built
mkdir build && $_
cmake install ..
If you don't want to build the example included with this repository just:
cmake install .. -DBUILD_EXAMPLES=OFF
Also to build without tests just add the option -DBUILD_TESTS=OFF
Finally make the library available widely in your system:
make && sudo make install
The library provides a simple interface in order to parser the message. As of now the two methods that you'll use most the time are:
-
fixparser::checkMsgValidity()
: which takes any thing that astd::string
can be constructed from and returntrue
if the message is a valid one or false otherwise. When it returnsfalse
meaning that the message is not valid, you can print the list of errors that occured during the parsing by printingfixparaser::getErrors()
to the standard output. -
fixparser::toHuman()
: Will display the parsed message in a human readable way. If the call tofixparser::checkMsgValidity
returned false then this function will print the list of errors encountered instead.
#include "fixparser.hpp"
#include <iostream>
auto main() -> int {
std::string msg("8=FIX.4.4|9=114|35=V|34=2|49=TRADEBOTMD002|52=20180425-17:51:40.000|56=BITWYRE|262=2|263=1|264=1|265=0|146=1|55=BTCUSD|267=1|269=0|10=016|");
auto isMsgValid = fixparser::checkMsgValidity(msg);
if( isMsgValid ){
std::cout<< fixparser::toHuman() <<"\n";
}else{
std::cout << fixparser::getErrors() << "\n";
}
return 1;
}
- GNU GPL v3