JayBeams  0.1
Another project to have fun coding.
Public Types | Public Member Functions | Private Attributes | List of all members
jb::itch5::order_book< book_type > Class Template Reference

Maintain the ITCH-5.0 order book for a single security. More...

#include <order_book.hpp>

Public Types

using book_type_config = typename book_type::config
 

Public Member Functions

 order_book (book_type_config const &cfg)
 Initialize an empty order book. More...
 
bool handle_add_order (buy_sell_indicator_t side, price4_t px, int qty)
 Handle a new order. More...
 
bool handle_order_reduced (buy_sell_indicator_t side, price4_t px, int reduced_qty)
 Handle an order reduction, which includes executions, cancels and replaces. More...
 
Accessors
half_quote best_bid () const
 
half_quote worst_bid () const
 
half_quote best_offer () const
 
half_quote worst_offer () const
 
book_depth_t buy_count () const
 
book_depth_t sell_count () const
 
book_depth_t get_book_depth () const
 

Private Attributes

book_type::buys_t buy_
 
book_type::sells_t sell_
 

Detailed Description

template<typename book_type>
class jb::itch5::order_book< book_type >

Maintain the ITCH-5.0 order book for a single security.

ITCH-5.0, like other market data feeds provide order-by-order detail, that is, the feed includes a message for each order received by the exchange, as well as the changes to these orders, i.e. when the execute, when their quantity (and/or price) is modified, and when they are canceled.. Such feeds are sometimes called Level III feeds. Typically only orders that do not immediately execute in full are included in the feed.

There is substantial variation in the format of the messages, and some variation as to whether executions are represented differently than a partial cancel, and whether changes in price are allowed or create new order ids.

This class encapsulates the order book data structure as well as its configuration.

This class receives a stream of (unnormalized) ITCH-5.0 messages for a single security, and organizes the orders in a book, i.e. a data structure where orders at the same price are grouped together, and one can quickly ask:

This is a template class.

Template Parameters
book_typedefines data structure type of price book, both sides buy and sell. Must be compatible with jb::itch5::map_based_order_book
Parameters
cfgbook_type config

Definition at line 57 of file order_book.hpp.

Member Typedef Documentation

◆ book_type_config

template<typename book_type>
using jb::itch5::order_book< book_type >::book_type_config = typename book_type::config

Definition at line 59 of file order_book.hpp.

Constructor & Destructor Documentation

◆ order_book()

template<typename book_type>
jb::itch5::order_book< book_type >::order_book ( book_type_config const &  cfg)
inlineexplicit

Initialize an empty order book.

Definition at line 62 of file order_book.hpp.

Member Function Documentation

◆ best_bid()

template<typename book_type>
half_quote jb::itch5::order_book< book_type >::best_bid ( ) const
inline
Returns
the best bid price and quantity

Definition at line 73 of file order_book.hpp.

References jb::itch5::order_book< book_type >::buy_.

Referenced by jb::itch5::generate_inside(), and jb::itch5::record_latency_stats().

◆ best_offer()

template<typename book_type>
half_quote jb::itch5::order_book< book_type >::best_offer ( ) const
inline
Returns
the best offer price and quantity

Definition at line 83 of file order_book.hpp.

References jb::itch5::order_book< book_type >::sell_.

Referenced by jb::itch5::generate_inside(), and jb::itch5::record_latency_stats().

◆ buy_count()

template<typename book_type>
book_depth_t jb::itch5::order_book< book_type >::buy_count ( ) const
inline

◆ get_book_depth()

template<typename book_type>
book_depth_t jb::itch5::order_book< book_type >::get_book_depth ( ) const
inline
Returns
the book depth, this is the number of price levels on this order book.

Definition at line 101 of file order_book.hpp.

References jb::itch5::order_book< book_type >::buy_count(), and jb::itch5::order_book< book_type >::sell_count().

◆ handle_add_order()

template<typename book_type>
bool jb::itch5::order_book< book_type >::handle_add_order ( buy_sell_indicator_t  side,
price4_t  px,
int  qty 
)
inline

Handle a new order.

Update the quantity at the right price level in the correct side of the book.

Parameters
sidewhether the order is a buy or a sell
pxthe price of the order
qtythe quantity of the order
Returns
true if the inside changed

Definition at line 118 of file order_book.hpp.

References jb::itch5::order_book< book_type >::buy_, and jb::itch5::order_book< book_type >::sell_.

◆ handle_order_reduced()

template<typename book_type>
bool jb::itch5::order_book< book_type >::handle_order_reduced ( buy_sell_indicator_t  side,
price4_t  px,
int  reduced_qty 
)
inline

Handle an order reduction, which includes executions, cancels and replaces.

Parameters
sidewhether the order is a buy or a sell
pxthe price of the order
reduced_qtythe executed quantity of the order
Returns
true if the inside changed

Definition at line 134 of file order_book.hpp.

References jb::itch5::order_book< book_type >::buy_, and jb::itch5::order_book< book_type >::sell_.

Referenced by jb::itch5::compute_book< book_type >::do_reduce().

◆ sell_count()

template<typename book_type>
book_depth_t jb::itch5::order_book< book_type >::sell_count ( ) const
inline

◆ worst_bid()

template<typename book_type>
half_quote jb::itch5::order_book< book_type >::worst_bid ( ) const
inline
Returns
the worst bid price and quantity

Definition at line 78 of file order_book.hpp.

References jb::itch5::order_book< book_type >::buy_.

◆ worst_offer()

template<typename book_type>
half_quote jb::itch5::order_book< book_type >::worst_offer ( ) const
inline
Returns
the worst offer price and quantity

Definition at line 88 of file order_book.hpp.

References jb::itch5::order_book< book_type >::sell_.

Member Data Documentation

◆ buy_

template<typename book_type>
book_type::buys_t jb::itch5::order_book< book_type >::buy_
private

◆ sell_

template<typename book_type>
book_type::sells_t jb::itch5::order_book< book_type >::sell_
private

The documentation for this class was generated from the following file: