Defining Securities of Interest
By default, the Handler processes market data for all securities available in a particular MarketSubscription. For certain subscriptions, the data may be large enough to cause the Handler to allocate significant system resources (e.g., memory). On the other hand, it often happens that not all securities are of interest. For these reasons, the Handler provides an ability to define a subset of securities for which the Handler will monitor market data, maintain books and report on other market-related events. No events will be fired by the Handler for any security not present in the defined subset. This feature is called selecting securities or security filtering.
There are two ways (which can be combined) to create and modify a security filter:
- The MarketSubscription::marketIds container can be used to collect securities for which the Handler should process market data. There are no limits on the quantity of securities which can be included in the selection. This way, securities can be filtered by market ID only.
- Special parameter isInterested of the ExchangeListener::onFuturesProductDefinition, ExchangeListener::onFuturesStrategyDefinition, ExchangeListener::onNewFuturesStrategyDefinition, ExchangeListener::onOptionsProductDefinition, ExchangeListener::onNewOptionsMarketDefinition, ExchangeListener::onOptionsStrategyDefinition, ExchangeListener::onNewOptionsStrategyDefinition, ExchangeListener::onNewExpiry callbacks can be used to add security to the security filter. This way, securities can be filtered by any attributes.
If at least one security is added to the filter, the Handler stops raising events for all securities available in the market data channel. Since that moment, the Handler fires events only for securities included in the filter. An empty (blank) security selection causes the Handler to process market data and trigger events for all securities in the market data feed.
- Note
- Selecting securities affects ExchangeListener, OrderBookChangeListener, OrderBookUpdateListener and OrderBookBundleUpdateListener listeners only. Handler does not invoke listener members for securities out of the selection scope. Other listeners are not affected by this feature.
- Attention
- Filtering can be manipulated only when the Handler is not processing market data or when the state is HandlerStates::SecurityDefinitionsRecoveryFinished. Once the Handler begins market data processing or exits the noted state scope, security selection does not affect the security filter.
Example
The following code demonstrates how to instruct the Handler to process data only for preselected securities:
"ConnectivityConfiguration.AP1.xml";
brentFutures.marketIds.insert(someMarketId);
subscriptions.insert(brentFutures);
handler.start(subscriptions);
The following code demonstrates how to instruct the Handler to add securities to the filter during security definition recovery:
virtual void onFuturesProductDefinition(
const FuturesProductDefinition& msg,
bool& isInterested) override
{
{
isInterested = true;
}
}