OnixS C++ CME Market Data Handler  4.8.0.10
API documentation
Pages/ManipulatingBooks.md
Go to the documentation of this file.
1 \addtogroup book-handling
2 
3 \brief Describes order book machinery.
4 
5 \section book-manipulations Order Books in the SDK
6 
7 CME MDP maintains market by price (price-level) and market by order
8 books. There are several types of books available for each security:
9 **Market By Order (MBO)**, **Direct**, **Implied** and **Consolidated**.
10 The SDK exposes the corresponding class for each of book type:
11 OnixS::CME::MDH::MboBook, OnixS::CME::MDH::DirectBook,
12 OnixS::CME::MDH::ImpliedBook and OnixS::CME::MDH::ConsolidatedBook.
13 Each class exposes exact data available for a particular kind of
14 the order book.
15 
16 
17 \note Although there are four different types of books, MDP
18 transmits data for only **MBO**, **direct** and **implied** types
19 of books. **Consolidated** books are being maintained by the Handler
20 locally using instances of **direct** and **implied** books
21 for a particular security.
22 
23 The Handler notifies a client code through the
24 OnixS::CME::MDH::SecurityListener::onBookUpdate callback
25 once a book of any type and for any security is updated.
26 
27 For market by price (MBP) books which **direct**, **implied** and **consolidated**
28 books are, the depth of book of a particular type is usually defined by security
29 definition and is exposed by the OnixS::CME::MDH::MbpBook::depth member. The returned
30 value defines the maximum number of price levels which may exist in the book.
31 
32 OnixS::CME::MDH::MbpBook::bids and OnixS::CME::MDH::MbpBook::asks
33 members of the OnixS::CME::MDH::MbpBook class can be used to access
34 price value and quantity information for all levels available in the book.
35 
36 Similarly, interface of class gathering MBO book data includes
37 OnixS::CME::MDH::MboBook::bids and OnixS::CME::MDH::MboBook::asks
38 members to access details for all orders available in the book.
39 
40 Also, order book maintenance is now explicitly defined by the Handler
41 configuration.
42 
43 The following code sample defines how to manage
44 maintenance of order books using Handler settings:
45 
46 ~~~{.cpp}
47 HandlerSettings settings;
48 
49 // Let Handler to maintain direct books. Once parameter is set
50 // to 'true', Handler will invoke SecurityListener::onBookUpdate()
51 // member passing instance of a valid direct book.
52 settings.bookManagement().directBooks().maintain(true);
53 
54 // Given statement suppresses implied order book maintenance.
55 // However, if consolidated order book maintenance is enabled,
56 // implied order book will also be maintained. Therefore, given
57 // statement only suppresses order book update event triggering.
58 settings.bookManagement().impliedBooks().maintain(false);
59 
60 
61 // Let Handler to maintain consolidated books. Once parameter
62 // is set to 'true', Handler will invoke SecurityListener::onBookUpdate()
63 // member passing instance of a valid consolidated book.
64 settings.bookManagement().consolidatedBooks().maintain(true);
65 ~~~
66 
67 Depth of a MBP book of a particular type is usually defined by
68 security definition and is exposed by OnixS::CME::MDH::Book::depth
69 member. Returned value defines maximum number of price levels which
70 may exist in a particular book instance.
71 
72 OnixS::CME::MDH::Book::bids and OnixS::CME::MDH::Book::offers
73 members of the OnixS::CME::MDH::Book class can be used to access
74 price value and quantity information for all levels available in
75 the book.
76 
77 \section behavior-traits Behavioral Traits
78 
79 The Handler constructs books for each security since the moment it receives
80 a definition for that security. **Books are changed in time, and their members
81 are not thread-safe**. The Handler uses own synchronization strategies while
82 updating the books. Therefore, **do not access price levels information outside
83 of book-related event handling** as well as **do not store references to any
84 book instance and data returned by its members** like asks and bids collections.
85 This restriction exists because the Handler may change internal book structures
86 at the same time. **If any data exposed by the OnixS::CME::MDH::Book class instance
87 must be used outside of event handling, it must be copied before later use**.
88 
89 \see \ref book-construction-and-copying, OnixS::CME::MDH::SecurityListener