B2BITS FIX Antenna C++  2.31.0
FIX Message Object Model

Table of Contents

In contrast to flat model (FIX Message) object model allows addressing messages and fields by names.

Although this interface is slower than the flat model, it may appear friendlier for Intellisense - the development-time on-line help.

Create

There is a dedicated namespace for each FIX protocol version. There is a dedicated class for each message type. To create "new order single" message using object model, simply create an instance of the corresponding class.

#include "B2BITS_Exception.h"
#include "B2BITS_FixEngine.h"
#include "b2bits/FixMessages/FIX44/Enums.h"
#include "b2bits/FixMessages/FIX44/AllMessages.h"
#include "b2bits/FixMessages/FIX44/Tags.h"
#include "b2bits/FixMessages/LocalMktDateType.h"
#include "b2bits/FixMessages/UTCTimestampType.h"
// ...
// Create "New order single" message for FIX 4.2
b2bits::FixMessages::FIX42::NewOrderSingleMessage order42;
// Create "Indication of Interest" message for FIX 4.4
b2bits::FixMessages::FIX44::IndicationOfInterestMessage ioi44;

Access fields

Fields can be accessed by names.

// Create "Execution Report" message for FIX 4.2
b2bits::FixMessages::FIX42::ExecutionReportMessage exec;
// Set ClOrdID field to "2247"
exec.OrderID().set("2247");
// Set ExecType field to Fill
exec.ExecType().set(ExecType::Fill);
exec.OrdStatus().set(OrdStatus::Filled);
exec.LeavesQty().set(0);
exec.TransactTime().set(UTCTimestampType::now());
// Remove OrderID field from message
exec.OrderID().remove();

Repeating groups

Repeating groups can be accessed by the name of the leading tag. Repeating group is treated as array, means that entries are accessed via indices.

// Create "Allocation instruction" message
AllocationInstructionMessage alloc;
// Create group "Orders"
AllocationInstructionMessage::OrdersGroup ordReportGrp = alloc.Orders();
// Set group size to 1 i.e. 1 entry
ordReportGrp.resize(1);
// Set ClOrdID field in the 1st entry to "1789"
ordReportGrp[0].ClOrdID().set("1789");
AllocationInstructionMessage::AllocsGroup allocInstrGrp = alloc.Allocs();
allocInstrGrp.resize(2);
allocInstrGrp[0].AllocAccount().set("Account1");
allocInstrGrp[0].AllocQty().set(4);
allocInstrGrp[1].AllocAccount().set("Account2");
allocInstrGrp[1].AllocQty().set(6);
// Remove group
alloc.Orders().remove();

Release

No specific actions are required to release resources.

Combine flat and object model

// Create object message from flat message
b2bits::FixMessages::FIX42::NewOrderSingleMessage order42(pOrder);
// Get flat message from object message
Engine::FIXMessage* pOrderNewPtr = order42.get();

Send object message

Object message can be send the same way as flat message

// ...
// Create object message from flat message
b2bits::FixMessages::FIX42::NewOrderSingleMessage order42(pOrder);
// Send message. All 3 instructions do the same.
pSn->put(pOrder);
pSn->put(order42);
pSn->put(order42.get());