OnixS C++ CME MDP Premium Market Data Handler  5.8.9
API Documentation
Event listeners

The handler uses a concept of events and event listeners to notify the client code about various aspects of market data processing and deliver data to the user (e.g., receiving a security definition or a direct book update).

The SDK groups events and provides classes with virtual members (event listeners) for each group. Client code may override any or all listener members to implement the processing of a particular event.

Associating an event listener with an instance of the OnixS::CME::MDH::Handler class is called subscribing to events.

Note
Associating the listener with the OnixS::CME::MDH::Handler instance must be performed while the handler is in the stopped state. Once the market data processing is started, assigning event listeners is not allowed and leads to throwing an exception.

Events groups

The table below describes events groups and shows the correspondence between the events, listeners and handler settings methods that are used to subscribe to events:

Listener Method Description
OnixS::CME::MDH::HandlerListener

OnixS::CME::MDH::HandlerListeners::handler

For example:

handler.settings().listeners().handler(&listener);
The handler invokes the event listener members during market data processing. Events reflect processing session stages like entering or leaving the recovery cycle, recovery completion status (OnixS::CME::MDH::RecoveryCompletionArgs), and resuming real-time data processing.
OnixS::CME::MDH::MarketDataListener

OnixS::CME::MDH::HandlerListeners::marketData

For example:

handler.settings().listeners().marketData(&listener);

The handler invokes the event listener members when it begins or ends processing various market data entities (e.g., a packet or a message).

Events are triggered only for market data accepted by the handler and according to CME's rules. The handler does not invoke members of the listener for any duplicated or out-of-order packets.

OnixS::CME::MDH::SecurityListener

OnixS::CME::MDH::HandlerListeners::security

For example:

handler.settings().listeners().security(&listener);

Members of the given listener are invoked to reflect security-related events like the receiving of trade, security status, and order book updates.

By default, members of this listener are invoked for each security available on the channel. However, it is possible to restrict callback invocation for a set of securities using the OnixS::CME::MDH::Handler::selectInstruments member. See Selecting securities of interest for more information.

OnixS::CME::MDH::ChannelFeedListener

OnixS::CME::MDH::HandlerListeners::feeds

For example:

handler.settings().listeners().feeds(&listener);

The OnixS::CME::MDH::ChannelFeedListener members are invoked each time a feed-related event occurs.

The sample below demonstrates listening to Handler's events:

struct
: public HandlerListener
, public MarketDataListener
, public SecurityListener
, public ChannelFeedListener
{
void onStarted(Handler&) override
{
std::cout << "Handler started." << std::endl;
}
void onStopped(Handler&) override
{
std::cout << "Handler stopped." << std::endl;
}
void onPacket(Handler&, const PacketArgs& args) override
{
std::cout << "A packet with sequence number " << args.seqNumber() << " is received." << std::endl;
}
void onBookUpdate(Handler&, const Security&, const ConsolidatedBook& book) override
{
std::cout << "A book is updated: " << brief(book) << std::endl;
}
void onFeedConnected(Handler&, const NetFeed& feed) override
{
std::cout << "Feed " << feed.id() << " is connected." << std::endl;
}
void onFeedDisconnected(Handler&, const NetFeed& feed) override
{
std::cout << "Feed " << feed.id() << " is disconnected." << std::endl;
}
}
listener;
handler.settings().listeners()
.handler(&listener)
.marketData(&listener)
.security(&listener)
.feeds(&listener);