BetaTrader
A HFT Eco-System
Loading...
Searching...
No Matches
trading_core::OrderBook Class Reference

Represents the order book for a single financial instrument. More...

#include <OrderBook.h>

Collaboration diagram for trading_core::OrderBook:
Collaboration graph

Public Types

using AskMap = std::map< common::Price, PriceLevel >
 A map of prices to price levels for sell orders, sorted in ascending order.
 
using BidMap = std::map< common::Price, PriceLevel, std::greater<> >
 A map of prices to price levels for buy orders, sorted in descending order.
 
using PriceLevel = std::deque< common::Order * >
 A deque of orders at a specific price level.
 

Public Member Functions

 OrderBook (common::Symbol symbol, MarketDataPublisher &publisher)
 Constructs a new OrderBook.
 
virtual ~OrderBook ()=default
 
virtual bool cancelOrder (const common::OrderID &orderId)
 Cancels an order from the order book.
 
virtual AskMapgetAskMap ()
 Gets a raw pointer to the ask map.
 
virtual BidMapgetBidMap ()
 Gets a raw pointer to the bid map.
 
virtual void insertOrder (common::Order *order)
 Inserts an order into the order book.
 
virtual void publishSnapshot (common::SessionID sessionId) const
 Publishes a full snapshot of the current order book for a specific session.
 

Private Attributes

AskMap mAskMap
 The map of sell orders.
 
BidMap mBidMap
 The map of buy orders.
 
MarketDataPublishermPublisher
 
common::Symbol mSymbol
 

Detailed Description

Represents the order book for a single financial instrument.

The order book maintains two separate books for buy (bid) and sell (ask) orders, organized by price levels. It provides methods for inserting and canceling orders and publishes market data updates.

Member Typedef Documentation

◆ AskMap

A map of prices to price levels for sell orders, sorted in ascending order.

◆ BidMap

using trading_core::OrderBook::BidMap = std::map<common::Price, PriceLevel, std::greater<> >

A map of prices to price levels for buy orders, sorted in descending order.

◆ PriceLevel

A deque of orders at a specific price level.

Constructor & Destructor Documentation

◆ OrderBook()

trading_core::OrderBook::OrderBook ( common::Symbol  symbol,
MarketDataPublisher publisher 
)

Constructs a new OrderBook.

Parameters
symbolThe symbol this order book represents.
publisherA reference to the market data publisher.

◆ ~OrderBook()

virtual trading_core::OrderBook::~OrderBook ( )
virtualdefault

Member Function Documentation

◆ cancelOrder()

bool trading_core::OrderBook::cancelOrder ( const common::OrderID orderId)
virtual

Cancels an order from the order book.

Parameters
orderIdThe ID of the order to be cancelled.
Returns
True if the order was successfully cancelled, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAskMap()

OrderBook::AskMap * trading_core::OrderBook::getAskMap ( )
virtual

Gets a raw pointer to the ask map.

Returns
A raw pointer to the ask map.
Here is the caller graph for this function:

◆ getBidMap()

OrderBook::BidMap * trading_core::OrderBook::getBidMap ( )
virtual

Gets a raw pointer to the bid map.

Returns
A raw pointer to the bid map.
Here is the caller graph for this function:

◆ insertOrder()

void trading_core::OrderBook::insertOrder ( common::Order order)
virtual

Inserts an order into the order book.

Parameters
orderA raw pointer to the order to be inserted.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ publishSnapshot()

void trading_core::OrderBook::publishSnapshot ( common::SessionID  sessionId) const
virtual

Publishes a full snapshot of the current order book for a specific session.

Parameters
sessionIdThe session to send the snapshot to.
Here is the call graph for this function:

Member Data Documentation

◆ mAskMap

AskMap trading_core::OrderBook::mAskMap
private

The map of sell orders.

◆ mBidMap

BidMap trading_core::OrderBook::mBidMap
private

The map of buy orders.

◆ mPublisher

MarketDataPublisher& trading_core::OrderBook::mPublisher
private

◆ mSymbol

common::Symbol trading_core::OrderBook::mSymbol
private

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