1 \addtogroup book-construction-and-copying
3 \brief Explains how to construct instances of
4 order books and to copy content across books.
6 Although the Handler constructs and updates order books
7 internally exposing already ready-to-use instances of books
8 through callbacks, SDK provides the ability to construct and
9 manipulate order books by users.
11 \section book-factory Constructing Book Instances
13 There're two types of books exposed by SDK: *MBO* (Market By Order)
14 and *MBP* (Market By Price). The last one in its turn consists of
15 three types: *Direct*, *Implied*, *Consolidated*. For each type of books,
16 the Handler provides instance constructing patterns.
18 \subsection mbp-book-factory Constructing MBP (Market By Price) Books
20 MBP books are limited in size (depth). CME MDP provides information on
21 book depth in instrument definitions. Therefore, the Handler knowns the
22 book depth as soon as it receives a definition for a security.
24 To make book operations efficient, SDK optimizes memory allocation
25 and data layout for MBP books. Therefore, construction of MBP books
26 and further lifetime management are performed through the use of
27 special factory classes. The Table below maps factory-classes to
28 corresponding book types.
30 | Book Class | Factory Class |
31 |------------------|-------------------------|
32 | DirectBook | DirectBookFactory |
33 | ImpliedBook | ImpliedBookFactory |
34 | ConsolidatedBook | ConsolidatedBookFactory |
36 Each of factory classes, in fact, represents an instantiation of
37 the OnixS::CME::MDH::MbpBookFactory template class which provides
38 the following key members:
40 | Member | Description |
42 | OnixS::CME::MDH::MbpBookFactory::construct | Constructs an instance of book of a particular type. |
43 | OnixS::CME::MDH::MbpBookFactory::destruct | Destroys an instance of the book of a particular type and disposes all allocated resources. |
44 | OnixS::CME::MDH::MbpBookFactory::calcSize | Calculates the size of memory block required to store an instance of the book of a given depth. |
45 | OnixS::CME::MDH::MbpBookFactory::inplaceConstruct | Constructs an instance of book in place of a given memory block. |
47 \subsection mbo-book-factory Constructing MBO (Market By Order) Books
49 MBO books in contrast to MBP ones are not limited by depth and may
50 contain an arbitrary number of bids and offers. Therefore, an instance of
51 the book cannot be placed in a flat memory block of fixed size. For this
52 reason, there's no factory class constructing MBO book instances using
53 special memory layout. Instead, the instances of the OnixS::CME::MDH::MboBook
54 class are constructed in an ordinary way.
56 \section book-copying Coping Book Content
58 The SDK offers the OnixS::CME::MDH::copy routine
59 to copy a book content across instances.
61 A template version of given routine copies a price level and other data
62 for MBP books. Also, the routine has an optional parameter which allows
63 limiting a number of price levels to copy.
65 Overload of the OnixS::CME::MDH::copy routine for MBO books represents
66 a wrapper over the OnixS::CME::MDH::MboBook assignment operator.