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

Manages all the orders in the system. More...

#include <OrderManager.h>

Collaboration diagram for trading_core::OrderManager:
Collaboration graph

Public Member Functions

 OrderManager ()=default
 Default constructor.
 
virtual ~OrderManager ()=default
 
virtual bool addOrder (std::unique_ptr< common::Order > order)
 Adds an order to the order manager.
 
bool containsOrderById (const common::OrderID &id) const
 Checks if an order exists in the order manager.
 
virtual std::optional< common::Order * > getOrderByClientOrderId (const std::string &clOrdId) const
 Gets an order by its client-assigned ID.
 
virtual std::optional< common::Order * > getOrderById (const common::OrderID &id) const
 Gets an order by its core ID.
 
const std::unordered_map< common::OrderID, std::unique_ptr< common::Order > > & getOrders () const
 Gets a const reference to the underlying order map.
 
virtual bool removeOrderById (const common::OrderID &id)
 Removes an order by its ID.
 
size_t size () const
 Gets the number of orders in the order manager.
 

Private Attributes

std::unordered_map< common::OrderID, std::unique_ptr< common::Order > > mOrderMap
 A map of order IDs to orders.
 

Detailed Description

Manages all the orders in the system.

This class is responsible for adding, removing, and retrieving orders. It stores all orders in an unordered map, using the order ID as the key.

Constructor & Destructor Documentation

◆ ~OrderManager()

virtual trading_core::OrderManager::~OrderManager ( )
virtualdefault

◆ OrderManager()

trading_core::OrderManager::OrderManager ( )
default

Default constructor.

Member Function Documentation

◆ addOrder()

bool trading_core::OrderManager::addOrder ( std::unique_ptr< common::Order order)
virtual

Adds an order to the order manager.

Parameters
orderA unique pointer to the order to be added.
Returns
True if the order was successfully added, false otherwise.
Here is the caller graph for this function:

◆ containsOrderById()

bool trading_core::OrderManager::containsOrderById ( const common::OrderID id) const

Checks if an order exists in the order manager.

Parameters
idThe ID of the order to check.
Returns
True if the order exists, false otherwise.

◆ getOrderByClientOrderId()

std::optional< common::Order * > trading_core::OrderManager::getOrderByClientOrderId ( const std::string &  clOrdId) const
virtual

Gets an order by its client-assigned ID.

Parameters
clOrdIdThe client order ID to search for.
Returns
An optional containing a raw pointer to the order if found.

◆ getOrderById()

std::optional< common::Order * > trading_core::OrderManager::getOrderById ( const common::OrderID id) const
virtual

Gets an order by its core ID.

Parameters
idThe ID of the order to retrieve.
Returns
An optional containing a raw pointer to the order if it was found, otherwise an empty optional.
Here is the caller graph for this function:

◆ getOrders()

const std::unordered_map< common::OrderID, std::unique_ptr< common::Order > > & trading_core::OrderManager::getOrders ( ) const

Gets a const reference to the underlying order map.

Returns
A const reference to the order map.

◆ removeOrderById()

bool trading_core::OrderManager::removeOrderById ( const common::OrderID id)
virtual

Removes an order by its ID.

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

◆ size()

size_t trading_core::OrderManager::size ( ) const

Gets the number of orders in the order manager.

Returns
The number of orders.

Member Data Documentation

◆ mOrderMap

std::unordered_map<common::OrderID, std::unique_ptr<common::Order> > trading_core::OrderManager::mOrderMap
private

A map of order IDs to orders.


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