BetaTrader
A HFT Eco-System
Loading...
Searching...
No Matches
OrderBook.h
Go to the documentation of this file.
1//
2// Created by sujal on 22-10-2025.
3//
4
5#pragma once
6#include "common/Order.h"
7#include "common/Types.h"
9#include <deque>
10#include <map>
11#include <memory>
12
13namespace trading_core {
22 class OrderBook {
23 public:
27 using PriceLevel = std::deque<common::Order*>;
28
33 using BidMap = std::map<common::Price, PriceLevel, std::greater<>>;
34
39 using AskMap = std::map<common::Price, PriceLevel>;
40
47 virtual ~OrderBook() = default;
48
53 virtual void insertOrder(common::Order* order);
54
61 virtual bool cancelOrder(const common::OrderID& orderId);
62
67 virtual void publishSnapshot(common::SessionID sessionId) const;
68
73 [[nodiscard]] virtual BidMap* getBidMap();
74
79 [[nodiscard]] virtual AskMap* getAskMap();
80
81 private:
86 };
87} // namespace trading_core
Represents a single trading order in the system.
Definition Order.h:19
Definition MarketDataPublisher.h:12
Represents the order book for a single financial instrument.
Definition OrderBook.h:22
MarketDataPublisher & mPublisher
Definition OrderBook.h:85
virtual ~OrderBook()=default
AskMap mAskMap
The map of sell orders.
Definition OrderBook.h:83
virtual bool cancelOrder(const common::OrderID &orderId)
Cancels an order from the order book.
Definition OrderBook.cpp:38
virtual void publishSnapshot(common::SessionID sessionId) const
Publishes a full snapshot of the current order book for a specific session.
Definition OrderBook.cpp:107
std::map< common::Price, PriceLevel > AskMap
A map of prices to price levels for sell orders, sorted in ascending order.
Definition OrderBook.h:39
virtual AskMap * getAskMap()
Gets a raw pointer to the ask map.
Definition OrderBook.cpp:158
virtual BidMap * getBidMap()
Gets a raw pointer to the bid map.
Definition OrderBook.cpp:153
std::map< common::Price, PriceLevel, std::greater<> > BidMap
A map of prices to price levels for buy orders, sorted in descending order.
Definition OrderBook.h:33
BidMap mBidMap
The map of buy orders.
Definition OrderBook.h:82
common::Symbol mSymbol
Definition OrderBook.h:84
virtual void insertOrder(common::Order *order)
Inserts an order into the order book.
Definition OrderBook.cpp:12
std::deque< common::Order * > PriceLevel
A deque of orders at a specific price level.
Definition OrderBook.h:27
Instrument
Represents the financial instruments available for trading.
Definition Instrument.h:17
uint64_t OrderID
A type alias for unique order identifiers.
Definition Types.h:134
uint64_t SessionID
A type alias for session identifiers.
Definition Types.h:142
Definition CancelOrder.h:10