1 \addtogroup security-selection
3 \brief Provides information on how to make Handler raise
4 security-related events for particular securities only.
6 \section define-security-selection Defining Securities of Interest
8 By default, the Handler processes market data for all securities available
9 in a particular market data channel. For certain channels, it may be a huge
10 amount of data which may cause the Handler to allocate a significant amount
11 of system resources (like a memory). From the other side, it often happens
12 that not all securities are the point of interest. For these reasons, the
13 Handler provides an ability to define a subset of securities for which it
14 monitors market data, maintains books and report about other market-related
15 events. The Handler fires no events for any security not present in the
16 defined subset. This feature is called *selecting securities or security
19 Selecting securities is similar to the process of filling a bag with
20 apples. The OnixS::CME::MDH::InstrumentSelection class must be used to
21 gather securities into a collection for which the Handler must process
22 market data. There're no limits on the quantity of securities which can
23 be included into the selection.
25 If at least one security is added to the filter, the Handler stops
26 raising events for all securities available in the market data channel.
27 Since that moment the Handler fires events only for securities included
30 Securities can be filtered using security id, security group,
31 symbol, and asset attributes. For each of these attributes, the
32 OnixS::CME::MDH::InstrumentSelection class exposes the corresponding
33 member returning a collection of attribute values which can be
34 manipulated as the regular std::set.
36 An empty (blank) security selection causes the Handler to process
37 market data and to trigger events for all securities on the channel.
39 \note Selecting securities affects the OnixS::CME::MDH::SecurityListener
40 listener only. The Handler does not invoke listener members for securities
41 out of the selection scope. Other listeners are not affected by this feature.
43 \warning **Filtering must be manipulated only when the
44 Handler is not processing market data or in bounds of the
45 OnixS::CME::MDH::HandlerListener::onEndOfInstrumentRecovery
46 callback with a successful recovery status. Once the Handler
47 begins market data processing or moves out of the noted callback
48 scope, security selection must not be modified.**
50 \section security-filter-example Example
52 The following code demonstrates how to instruct the Handler
53 to process data only for securities selected by the user:
57 using namespace OnixS::CME::MDH;
60 InteractiveSecuritySelector
61 : public SecurityListener
62 , public HandlerListener
64 InstrumentSelection selection_;
72 const Definition& definition)
74 // Given member asks user whether user wants
75 // to have market data for given instrument.
76 // Returned value indicates whether user
77 // selected instrument.
83 InteractiveSecuritySelector()
90 const Security& security,
91 const InstrumentDefinitionFutureArgs& args)
93 if (userSelectedSecurity(args.message())
94 selection_.securityIds().insert(security.id());
100 const Security& security,
101 const InstrumentDefinitionSpreadArgs& args)
103 if (userSelectedSecurity(args.message())
104 selection_.securityIds().insert(security.id());
110 const Security& security,
111 const InstrumentDefinitionOptionArgs& args)
113 if (userSelectedSecurity(args.message())
114 selection_.securityIds().insert(security.id());
118 onEndOfInstrumentRecovery(
120 const RecoveryCompletionArgs& args)
123 RecoveryCompletionStatus::Succeeded)
125 handler.selectInstruments(selection_);
130 Handler handler(settings);
132 InteractiveSecuritySelector selector;
134 handler.registerSecurityListener(selector);
135 handler.registerListener(selector);