CBOE Emulator  1.0
Classes | Typedefs | Enumerations | Functions
DataFeed::LOB Namespace Reference

Logic for maintaining a continuous double auction via a limit-order book. More...

Classes

struct  Limit
 A price limit containing a FIFO queue of Order objects. More...
 
class  LimitOrderBook
 An order book for managing Limit / Order objects in a continuous double auction. More...
 
struct  LimitTree
 A single side (buy/sell) of the LimitOrderBook. More...
 
struct  Order
 A single order in the LimitOrderBook. More...
 

Typedefs

typedef std::unordered_map< UID, OrderUIDOrderMap
 a map of order IDs to orders
 
typedef tsl::robin_map< Price, Limit * > PriceLimitMap
 a map of prices to limit pointers
 
typedef uint64_t UID
 a type for order IDs
 
typedef uint32_t Quantity
 a type for order quantities
 
typedef uint64_t Price
 a type for order prices
 
typedef uint32_t Count
 a type for limit price order counts
 
typedef uint64_t Volume
 a type for limit total volume
 

Enumerations

enum  Side : bool { Sell = false, Buy = true }
 the possible sides for the LimitTree
 

Functions

template<Side side>
void set_best (Limit **best, Limit *limit)
 Set the best to the given limit if the given limit is better. More...
 
template<>
void set_best< Side::Buy > (Limit **highest_buy, Limit *limit)
 Set the best buy to the given limit if the given limit is better. More...
 
template<>
void set_best< Side::Sell > (Limit **lowest_sell, Limit *limit)
 Set the best sell to the given limit if the given limit is better. More...
 
template<Side side>
void find_best (Limit **best)
 Find the next best when removing the best from the tree. More...
 
template<>
void find_best< Side::Buy > (Limit **highest_buy)
 Find the next buy when removing the best buy from the tree. More...
 
template<>
void find_best< Side::Sell > (Limit **lowest_sell)
 Find the next sell when removing the best sell from the tree. More...
 
template<Side side>
bool can_match (Price limit, Price market)
 Return true if the market price can match with the limit price. More...
 
template<>
bool can_match< Side::Buy > (Price limit, Price market)
 Return true if the sell market price can match with the buy limit price. More...
 
template<>
bool can_match< Side::Sell > (Price limit, Price market)
 Return true if the buy market price can match with the sell limit price. More...
 
Side operator! (Side side)
 Return the opposite side using the invert operator. More...
 

Detailed Description

Logic for maintaining a continuous double auction via a limit-order book.

Function Documentation

◆ can_match()

template<Side side>
bool DataFeed::LOB::can_match ( Price  limit,
Price  market 
)

Return true if the market price can match with the limit price.

Template Parameters
sidethe side of the book to perform the calculation from
Parameters
limitthe price of the limit order (i.e., the best price)
marketthe price of the opposing side market order to compare
Returns
true if the market price can match with the limit price

◆ can_match< Side::Buy >()

template<>
bool DataFeed::LOB::can_match< Side::Buy > ( Price  limit,
Price  market 
)
inline

Return true if the sell market price can match with the buy limit price.

Parameters
limitthe price of the buy limit order (i.e., the best price)
marketthe price of the sell side market order to compare
Returns
true if the sell market price can match with the buy limit price

◆ can_match< Side::Sell >()

template<>
bool DataFeed::LOB::can_match< Side::Sell > ( Price  limit,
Price  market 
)
inline

Return true if the buy market price can match with the sell limit price.

Parameters
limitthe price of the sell limit order (i.e., the best price)
marketthe price of the buy side market order to compare
Returns
true if the buy market price can match with the sell limit price

◆ find_best()

template<Side side>
void DataFeed::LOB::find_best ( Limit **  best)

Find the next best when removing the best from the tree.

Template Parameters
sidethe side of the book to perform the calculation from
Parameters
bestthe best limit node

◆ find_best< Side::Buy >()

template<>
void DataFeed::LOB::find_best< Side::Buy > ( Limit **  highest_buy)
inline

Find the next buy when removing the best buy from the tree.

Parameters
highest_buythe best buy limit node

◆ find_best< Side::Sell >()

template<>
void DataFeed::LOB::find_best< Side::Sell > ( Limit **  lowest_sell)
inline

Find the next sell when removing the best sell from the tree.

Parameters
lowest_sellthe best sell limit node

◆ operator!()

Side DataFeed::LOB::operator! ( Side  side)
inline

Return the opposite side using the invert operator.

Parameters
sidethe side to invert
Returns
the opposite of the given side

◆ set_best()

template<Side side>
void DataFeed::LOB::set_best ( Limit **  best,
Limit limit 
)

Set the best to the given limit if the given limit is better.

Template Parameters
sidethe side of the book to perform the calculation from
Parameters
bestthe current best limit
limitthe limit node to compare to

◆ set_best< Side::Buy >()

template<>
void DataFeed::LOB::set_best< Side::Buy > ( Limit **  highest_buy,
Limit limit 
)
inline

Set the best buy to the given limit if the given limit is better.

Parameters
highest_buythe current best buy limit
limitthe buy limit node to compare to

◆ set_best< Side::Sell >()

template<>
void DataFeed::LOB::set_best< Side::Sell > ( Limit **  lowest_sell,
Limit limit 
)
inline

Set the best sell to the given limit if the given limit is better.

Parameters
lowest_sellthe current best sell limit
limitthe sell limit node to compare to