OnixS C++ CME MDP Conflated UDP Handler  1.1.2
API documentation
Processing Market Data In FIX-like Manner

In order to provide a uniform technique to deal with the SBE messages, the SDK exposes FIX-like messaging subsystem. This subsystem represents additional layer between the SBE messages and user code. It allows users to achieve much higher tolerance to any changes in the SBE messaging including exchange-side ones by proving access to market data in the FIX-like (tag=value) way.

Warning
The FIX-like messaging subsystem is not intended to use in time-critical paths as it is designed to provide more flexibility in manipulating the market data, but it does not provide the fastest way to access the data.

All classes complying the subsystem are located in the OnixS::CME::ConflatedUDP::FIX namespace. To get the classes used, the following files must be included to the target project:

Constructing FIX Messages Manually

Every FIX-like message wrapper contains a constructor which allows to create an object from a corresponding message:

using namespace OnixS::CME::ConflatedUDP;
void
onMessage(
Handler& handler,
{
const FIX::Message& fixMessage =
// use fixMessage
}

Listening to FIX Messages

The SDK provides ability to subscribe to market data related notifications and obtain incoming market data wrapped into FIX containers instead of receiving SBE messages.

The OnixS::CME::ConflatedUDP::FIX::MessageListener class serves for the needs. Similar to the OnixS::CME::ConflatedUDP::MarketDataListener, the given class allows to get market data which is processed by the Handler. However, the data is exposed as FIX-like wrapper over the SBE content.

The user code must inherit from the given class and register the instance as the listener to market data. See Listening to Market Data for more information concerning how to get subscribed to market data events.

using namespace OnixS::CME::ConflatedUDP;
struct FixMessageListener
{
void
onMessage(
const FIX::MessageArgs& args)
{
// use args.message()
}
};
...
FixMessageListener listener;
handler.settings().listeners().marketData(&listener);

Using The FIX Messaging

The following example depicts how to access market data fields and groups using the FIX-like messaging subsystem:

using namespace OnixS::CME::ConflatedUDP;
void
trace(
const FIX::Message& message)
{
if (message.type() == "X")
{
const
transact =
message[
const
indicator =
message[
// Any time-stamp field can be successfully converted into
// unsigned 64-bit integer representing ticks since the epoch.
// Bit-set fields can be accessed either as raw integers or
// as structured entities as they are exposed by SBE messages.
std::cout
<< "Transact time: "
<< toStr(
transact.
cast<Timestamp>())
<< "."
<< std::endl
<< "Transact time (Ticks from Epoch): "
<< toStr(
transact.
cast<UInt64>())
<< "."
<< std::endl
<< "Event Indicator: "
<< toStr(
indicator.
cast<MatchEventIndicator>())
<< "."
<< std::endl
<< "Event Indicator (Raw Numeric Value): "
<< toStr(indicator.cast<UInt32>())
<< "."
<< std::endl;
const
entries =
message.group(
if (entries)
{
for (
Group::Size index = 0;
index != entries.size();
++index)
{
const GroupEntry entry = entries[index];
std::cout
<< "["
<< index
<< "] {Price=";
if (const Field px =
{
std::cout
<< toStr(
px.cast<Decimal>());
}
Int32 size;
// If side is not available then
// the casting operation will fail.
if (entry[
Tags::MDEntrySize].tryCast(size))
{
std::cout
<< ",Size="
<< size;
}
const
side =
entry[
std::cout
<< ",Side="
<< toStr(
side.
cast<EntryType>())
<< ",Side(Raw)="
<< toStr(
side.
cast<EntryType::Base>());
const
action =
entry[
// In addition to accessing the field value in a raw FIX
// format, it's possible to cast the value to the corresponding
// enumeration type. In such case, the field value can be
// compared with enumeration constants.
std::cout
<< ",Action="
<< toStr(
action.
cast<UpdateAction>())
<< ",Action(Raw)="
<< toStr(
action.
cast<UpdateAction::Base>());
std::cout
<< "}"
<< std::endl;
}
}
}
else if (message.type() == "d")
{
if (message[
].tryCast(mmy))
{
const
message[
].cast<SecurityId>();
std::cout
<< "Maturity Month-Year for $"
<< securityId
<< ": "
<< toStr(mmy)
<< std::endl;
}
}
}
class Tracer : FIX::MessageListener
{
void
onMessage(
const FIX::MessageArgs& args)
{
trace(args.message());
}
public:
// Configures sample.
Tracer(
Handler& handler)
{
handler.settings().listeners().marketData(this);
}
};