CppTrader 1.0.6.0
C++ Trader
Loading...
Searching...
No Matches
CppTrader::Matching::OrderBook Class Reference

Order book. More...

#include <order_book.h>

Public Types

typedef CppCommon::BinTreeAVL< LevelNode, std::less< LevelNode > > Levels
 Price level container.

Public Member Functions

 OrderBook (MarketManager &manager, const Symbol &symbol)
 OrderBook (const OrderBook &)=delete
 OrderBook (OrderBook &&)=delete
 ~OrderBook ()
OrderBook & operator= (const OrderBook &)=delete
OrderBook & operator= (OrderBook &&)=delete
 operator bool () const noexcept
 Check if the order book is not empty.
bool empty () const noexcept
 Is the order book empty?
size_t size () const noexcept
 Get the order book size.
const Symbol & symbol () const noexcept
 Get the order book symbol.
const LevelNode * best_bid () const noexcept
 Get the order book best bid price level.
const LevelNode * best_ask () const noexcept
 Get the order book best ask price level.
const Levels & bids () const noexcept
 Get the order book bids container.
const Levels & asks () const noexcept
 Get the order book asks container.
const LevelNode * best_buy_stop () const noexcept
 Get the order book best buy stop order price level.
const LevelNode * best_sell_stop () const noexcept
 Get the order book best sell stop order price level.
const Levels & buy_stop () const noexcept
 Get the order book buy stop orders container.
const Levels & sell_stop () const noexcept
 Get the order book sell stop orders container.
const LevelNode * best_trailing_buy_stop () const noexcept
 Get the order book best trailing buy stop order price level.
const LevelNode * best_trailing_sell_stop () const noexcept
 Get the order book best trailing sell stop order price level.
const Levels & trailing_buy_stop () const noexcept
 Get the order book trailing buy stop orders container.
const Levels & trailing_sell_stop () const noexcept
 Get the order book trailing sell stop orders container.
const LevelNode * GetBid (uint64_t price) const noexcept
 Get the order book bid price level with the given price.
const LevelNode * GetAsk (uint64_t price) const noexcept
 Get the order book ask price level with the given price.
const LevelNode * GetBuyStopLevel (uint64_t price) const noexcept
 Get the order book buy stop level with the given price.
const LevelNode * GetSellStopLevel (uint64_t price) const noexcept
 Get the order book sell stop level with the given price.
const LevelNode * GetTrailingBuyStopLevel (uint64_t price) const noexcept
 Get the order book trailing buy stop level with the given price.
const LevelNode * GetTrailingSellStopLevel (uint64_t price) const noexcept
 Get the order book trailing sell stop level with the given price.

Friends

class MarketManager
template<class TOutputStream>
TOutputStream & operator<< (TOutputStream &stream, const OrderBook &order_book)

Detailed Description

Order book.

Order book is used to keep buy and sell orders in a price level order.

Not thread-safe.

Examples
market_manager.cpp, and matching_engine.cpp.

Definition at line 28 of file order_book.h.

Member Typedef Documentation

◆ Levels

typedef CppCommon::BinTreeAVL<LevelNode, std::less<LevelNode> > CppTrader::Matching::OrderBook::Levels

Price level container.

Definition at line 34 of file order_book.h.

Constructor & Destructor Documentation

◆ OrderBook() [1/3]

CppTrader::Matching::OrderBook::OrderBook ( MarketManager & manager,
const Symbol & symbol )

Definition at line 15 of file order_book.cpp.

◆ OrderBook() [2/3]

CppTrader::Matching::OrderBook::OrderBook ( const OrderBook & )
delete

◆ OrderBook() [3/3]

CppTrader::Matching::OrderBook::OrderBook ( OrderBook && )
delete

◆ ~OrderBook()

CppTrader::Matching::OrderBook::~OrderBook ( )

Definition at line 33 of file order_book.cpp.

Member Function Documentation

◆ asks()

const Levels & CppTrader::Matching::OrderBook::asks ( ) const
inlinenoexcept

Get the order book asks container.

Definition at line 64 of file order_book.h.

◆ best_ask()

const LevelNode * CppTrader::Matching::OrderBook::best_ask ( ) const
inlinenoexcept

Get the order book best ask price level.

Definition at line 59 of file order_book.h.

◆ best_bid()

const LevelNode * CppTrader::Matching::OrderBook::best_bid ( ) const
inlinenoexcept

Get the order book best bid price level.

Definition at line 57 of file order_book.h.

◆ best_buy_stop()

const LevelNode * CppTrader::Matching::OrderBook::best_buy_stop ( ) const
inlinenoexcept

Get the order book best buy stop order price level.

Definition at line 67 of file order_book.h.

◆ best_sell_stop()

const LevelNode * CppTrader::Matching::OrderBook::best_sell_stop ( ) const
inlinenoexcept

Get the order book best sell stop order price level.

Definition at line 69 of file order_book.h.

◆ best_trailing_buy_stop()

const LevelNode * CppTrader::Matching::OrderBook::best_trailing_buy_stop ( ) const
inlinenoexcept

Get the order book best trailing buy stop order price level.

Definition at line 77 of file order_book.h.

◆ best_trailing_sell_stop()

const LevelNode * CppTrader::Matching::OrderBook::best_trailing_sell_stop ( ) const
inlinenoexcept

Get the order book best trailing sell stop order price level.

Definition at line 79 of file order_book.h.

◆ bids()

const Levels & CppTrader::Matching::OrderBook::bids ( ) const
inlinenoexcept

Get the order book bids container.

Definition at line 62 of file order_book.h.

◆ buy_stop()

const Levels & CppTrader::Matching::OrderBook::buy_stop ( ) const
inlinenoexcept

Get the order book buy stop orders container.

Definition at line 72 of file order_book.h.

◆ empty()

bool CppTrader::Matching::OrderBook::empty ( ) const
inlinenoexcept

Is the order book empty?

Definition at line 48 of file order_book.h.

◆ GetAsk()

const LevelNode * CppTrader::Matching::OrderBook::GetAsk ( uint64_t price) const
inlinenoexcept

Get the order book ask price level with the given price.

Parameters
price- Price
Returns
Pointer to the order book ask price level with the given price or nullptr

Definition at line 32 of file order_book.inl.

◆ GetBid()

const LevelNode * CppTrader::Matching::OrderBook::GetBid ( uint64_t price) const
inlinenoexcept

Get the order book bid price level with the given price.

Parameters
price- Price
Returns
Pointer to the order book bid price level with the given price or nullptr

Definition at line 26 of file order_book.inl.

◆ GetBuyStopLevel()

const LevelNode * CppTrader::Matching::OrderBook::GetBuyStopLevel ( uint64_t price) const
inlinenoexcept

Get the order book buy stop level with the given price.

Parameters
price- Price
Returns
Pointer to the order book buy stop level with the given price or nullptr

Definition at line 38 of file order_book.inl.

◆ GetSellStopLevel()

const LevelNode * CppTrader::Matching::OrderBook::GetSellStopLevel ( uint64_t price) const
inlinenoexcept

Get the order book sell stop level with the given price.

Parameters
price- Price
Returns
Pointer to the order book sell stop level with the given price or nullptr

Definition at line 44 of file order_book.inl.

◆ GetTrailingBuyStopLevel()

const LevelNode * CppTrader::Matching::OrderBook::GetTrailingBuyStopLevel ( uint64_t price) const
inlinenoexcept

Get the order book trailing buy stop level with the given price.

Parameters
price- Price
Returns
Pointer to the order book trailing buy stop level with the given price or nullptr

Definition at line 50 of file order_book.inl.

◆ GetTrailingSellStopLevel()

const LevelNode * CppTrader::Matching::OrderBook::GetTrailingSellStopLevel ( uint64_t price) const
inlinenoexcept

Get the order book trailing sell stop level with the given price.

Parameters
price- Price
Returns
Pointer to the order book trailing sell stop level with the given price or nullptr

Definition at line 56 of file order_book.inl.

◆ operator bool()

CppTrader::Matching::OrderBook::operator bool ( ) const
inlineexplicitnoexcept

Check if the order book is not empty.

Definition at line 45 of file order_book.h.

◆ operator=() [1/2]

OrderBook & CppTrader::Matching::OrderBook::operator= ( const OrderBook & )
delete

◆ operator=() [2/2]

OrderBook & CppTrader::Matching::OrderBook::operator= ( OrderBook && )
delete

◆ sell_stop()

const Levels & CppTrader::Matching::OrderBook::sell_stop ( ) const
inlinenoexcept

Get the order book sell stop orders container.

Definition at line 74 of file order_book.h.

◆ size()

size_t CppTrader::Matching::OrderBook::size ( ) const
inlinenoexcept

Get the order book size.

Definition at line 51 of file order_book.h.

◆ symbol()

const Symbol & CppTrader::Matching::OrderBook::symbol ( ) const
inlinenoexcept

Get the order book symbol.

Definition at line 54 of file order_book.h.

◆ trailing_buy_stop()

const Levels & CppTrader::Matching::OrderBook::trailing_buy_stop ( ) const
inlinenoexcept

Get the order book trailing buy stop orders container.

Definition at line 82 of file order_book.h.

◆ trailing_sell_stop()

const Levels & CppTrader::Matching::OrderBook::trailing_sell_stop ( ) const
inlinenoexcept

Get the order book trailing sell stop orders container.

Definition at line 84 of file order_book.h.

◆ MarketManager

friend class MarketManager
friend

Definition at line 30 of file order_book.h.

◆ operator<<

template<class TOutputStream>
TOutputStream & operator<< ( TOutputStream & stream,
const OrderBook & order_book )
friend

Definition at line 13 of file order_book.inl.


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