OnixS C++ CME Market Data Handler  2.56.0.0
Filtering Securities

Defining Securities of Interest

By default, Handler processes market data for all securities available in a particular market data channel. For certain channels, it may be a huge amount of data which may cause the Handler to allocate significant amount of system resources (like a memory). From other side, it often happens that not all securities are the point of interest. For these reasons, Handler provides an ability to define a subset of securities for which Handler will monitor market data, maintain books and report about changes in statistics. No events will be fired by the Handler for any security not present in the defined subset. This feature is called securities filtering.

Operating over securities filter is similar to the process of filling bag with apples. OnixS::CME::MarketData::Handler::addSecurityIdFilter member must be used to put a security into the collection of securities for which the Handler must process market data. There's no limits on quantity of securities which can be included into filtering. Client code may put from single up to all securities available in the single market data channel.

If at least one security is added to the filter, Handler stops raising events for all securities available in the market data channel. Since that moment Handler will fire events only for securities included into filtering.

To remove security from the filter, it's necessary to call OnixS::CME::MarketData::Handler::removeSecurityIdFilter member. Handler will continue processing market data and raising events only for the securities which remain in the filter.

If collection of securities in the filter becomes empty, Handler starts processing market data and event notifying for all securities in the market data channel.

To ensure no securities are available in the securities filter, use OnixS::CME::MarketData::Handler::removeAllSecurityIdFilters member. It will clear the filter.

Note
Filtering must be manipulated only when the Handler is in OnixS::CME::MarketData::HandlerStates::Stopped or in OnixS::CME::MarketData::HandlerStates::SecurityDefinitionsRecoveryStarted state. Once Handler changes its state to any other state, filters must not be modified.

Filtering Market Data by Other Criteria

In addition to filtering market data based on security identifiers, the Handler provides ability to filter market data using security symbol and group attributes.

Handler's interface includes addSecurity<FilterType>Filter, removeSecurity<FilterType>Filter and removeAllSecurity<FilterType>Filters set of members (where FilterType is either Symbol or Group) to filter market data using security symbol (value of OnixS::CME::MarketData::SecurityDefinition::securitySymbol field) and/or group (value of OnixS::CME::MarketData::SecurityDefinition::securityGroup field) attributes.

Note
It's possible to filter market data using different kinds of filters. When the Handler processes market data it's being passed through all the filters. Thus, Handler publishes market data processing results only when market data satisfies all filtering criteria.
Filtering is not applied by the Handler while processing security definitions.

Example

Following code demonstrates how to instruct the Handler to process data only for two particular securities:

using namespace OnixS::CME::MarketData;
Handler handler(handlerSettings);
handler.addSecurityIdFilter(5930);
handler.addSecurityIdFilter(5931);
handler.start();
...
handler.stop();
handler.removeAllSecurityIdFilters();