The Handler manages order books internally and exposes ready-to-use instances of books through the callbacks. However, the SDK provides the ability to construct and manipulate order books by users.
There're two types of books exposed by the MDP: MBO (Market By Order) and MBP (Market By Price). The last one in its turn consists of three types: Direct, Implied, Consolidated. The Handler provides instance constructing patterns for each book type.
MBP books are limited in size (depth). The MDP provides information on book depth in instrument definitions. Therefore, the Handler knows the book depth as soon as it receives a definition for an instrument.
To make book operations efficient, the SDK optimizes memory allocation and data layout for MBP books. Therefore, the construction of MBP books and further lifetime management are performed through special factory classes. The table below maps factory-classes to corresponding book types.
|Book Class||Factory Class|
Each factory class represents an instantiation of the OnixS::CME::MDH::MbpBookFactory template class, which provides the following key members:
|OnixS::CME::MDH::MbpBookFactory::construct||Constructs an instance of the book of a particular type.|
|OnixS::CME::MDH::MbpBookFactory::destruct||Destroys an instance of the book of a particular type and disposes all allocated resources.|
|OnixS::CME::MDH::MbpBookFactory::calcSize||Calculates the size of memory block required to store an instance of the book of a given depth.|
|OnixS::CME::MDH::MbpBookFactory::inplaceConstruct||Constructs an instance of book in place of a given memory block.|
MBO books, in contrast to MBP ones, are not limited by depth and may contain an arbitrary number of bids and offers. Therefore, an instance of the book cannot be placed in a flat memory block of fixed size. For this reason, there's no factory class constructing MBO book instances using special memory layout. Instead, the instances of the OnixS::CME::MDH::MboBook class are constructed ordinarily.
The SDK offers the OnixS::CME::MDH::copy routine to copy a book content across instances.
A template version of the given routine copies price levels and other data of MBP books. Also, the routine has an optional parameter limiting the number of price levels to copy.