OnixS CBOE CSM Handler for C++
Building Order Books
Advanced Programming

Handler is able to build internal Order Books. To activate this feature, set OnixS::CBOE::MarketData::CSM::HandlerSettings::buildInternalOrderBooks on and pass an instance of OnixS::CBOE::MarketData::CSM::OrderBookListener to OnixS::CBOE::MarketData::CSM::Handler::registerOrderBookListener.

OnixS::CBOE::MarketData::CSM::HandlerSettings::buildInternalOrderBooks is set by default.
If OnixS::CBOE::MarketData::CSM::HandlerSettings::buildInternalOrderBooks is set, but OnixS::CBOE::MarketData::CSM::OrderBookListener is not registered, OnixS::CBOE::MarketData::CSM::WarningListener::onWarning callback will be invoked with corresponding message.
If OnixS::CBOE::MarketData::CSM::HandlerSettings::buildInternalOrderBooks is not set, but OnixS::CBOE::MarketData::CSM::OrderBookListener is registered, OnixS::CBOE::MarketData::CSM::WarningListener::onWarning callback will be invoked with corresponding message.

To achieve better performance, the Order Books are created in preallocated memory area. To adjust preallocated memory pool size, set OnixS::CBOE::MarketData::CSM::HandlerSettings::maxBooksObjectAmount. The default value is 500;

If the preallocated objects amount is not enough to place, all the created books and the exception will be thrown when book creation fails.

HandlerSettings settings;
settings.buildInternalOrderBooks = true;
settings.maxBooksObjectAmount = 100;
// ...
Handler handler(settings);
BookListener listener;

If building internal Order Books is turned on correctly, corresponding callbacks will be invoked. OnixS::CBOE::MarketData::CSM::OrderBookListener::onOrderBookUpdated is invoked when any Order Book object's state is changed. A reference to corresponding Order Book object is passed into this callback.

Lifetime of the OnixS::CBOE::MarketData::CSM::OrderBook object, passed to the OnixS::CBOE::MarketData::CSM::OrderBookListener::onOrderBookUpdated callback, is unpredictable after returning from it. So the reference, passed into the callback, may become invalid at any time after returning from it and should not be stored. Read-only copy of the workbook can be created through the call to OnixS::CBOE::MarketData::CSM::OrderBook::snapshot(). Caller is responsible for the deletion of this book.

OnixS::CBOE::MarketData::CSM::OrderBookListener::onOrderBookInvalidated is invoked if Order Book object becomes invalidated because of detected message gaps or data loss. Corresponding Security ID is passed into the callback.