Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

gboncoffee/b3.h

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

b3.h

Definitions for B3 FIX/SBE messages.

To use it, just #include it as any other C header.

Compatibility

This is ISO C90 (-pedantic -ansi), but depends on extensions that GCC kindly does not disable (#pragma scalar_storage_order little-endian and __attribute__((packed))). Clang does fail to recognize the pragma and throws warnings ignoring it, but you will probably be fine in a little endian machine.

Usage

The protocol is simple enough to just cast pointers around. For example, assuming a packet was received and is stored in the buffer buf with size size:

size_t size;
uint8_t *buf = receive_buffer_from_somewhere(&size);

B3PacketHeader *header = (B3PacketHeader*) buf;
B3MessageHeader *first_msg = (B3MessageHeader*) (((size_t) buf) + sizeof(B3PacketHeader));
B3MessageHeader *second_msg = (B3MessageHeader*) (((size_t) first_msg) + first_msg->length);
/* And so on and so forth... */

switch (first_msg->template_id) {
case B3_HIGH_PRICE:
    B3MessageHighPrice *msg = (B3MessageHighPrice*) (((size_t) first_msg) + sizeof(B3MessageHeader));
    printf("Received high price message at %d", msg->md_entry_timestamp);
case B3_LOW_PRICE:
    B3MessageLowPrice *msg = (B3MessageHighPrice*) (((size_t) first_msg) + sizeof(B3MessageHeader));
    printf("Received high price message at %d", msg->md_entry_timestamp);
}

About

Definitions for B3 FIX/SBE messages

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages