BetaTrader
A HFT Eco-System
Loading...
Searching...
No Matches
OrderManager.h
Go to the documentation of this file.
1//
2// Created by sujal on 21-10-2025.
3//
4#pragma once
5#include "common/Order.h"
6#include "common/Types.h"
7#include <memory>
8#include <unordered_map>
9#include <optional>
10
11namespace trading_core {
20 public:
21 virtual ~OrderManager() = default;
22
26 OrderManager() = default;
27
28 public:
34 virtual bool addOrder(std::unique_ptr<common::Order> order);
35
42 [[nodiscard]] virtual std::optional<common::Order*>
43 getOrderById(const common::OrderID& id) const;
44
50 [[nodiscard]] virtual std::optional<common::Order*>
51 getOrderByClientOrderId(const std::string& clOrdId) const;
52
58 virtual bool removeOrderById(const common::OrderID& id);
59
65 bool containsOrderById(const common::OrderID& id) const;
66
71 size_t size() const;
72
77 const std::unordered_map<common::OrderID, std::unique_ptr<common::Order>>& getOrders() const;
78
79 private:
80 std::unordered_map<common::OrderID, std::unique_ptr<common::Order>>
82 };
83} // namespace trading_core
Manages all the orders in the system.
Definition OrderManager.h:19
virtual std::optional< common::Order * > getOrderById(const common::OrderID &id) const
Gets an order by its core ID.
Definition OrderManager.cpp:23
virtual ~OrderManager()=default
virtual bool removeOrderById(const common::OrderID &id)
Removes an order by its ID.
Definition OrderManager.cpp:46
const std::unordered_map< common::OrderID, std::unique_ptr< common::Order > > & getOrders() const
Gets a const reference to the underlying order map.
Definition OrderManager.cpp:65
std::unordered_map< common::OrderID, std::unique_ptr< common::Order > > mOrderMap
A map of order IDs to orders.
Definition OrderManager.h:81
virtual std::optional< common::Order * > getOrderByClientOrderId(const std::string &clOrdId) const
Gets an order by its client-assigned ID.
Definition OrderManager.cpp:33
size_t size() const
Gets the number of orders in the order manager.
Definition OrderManager.cpp:60
bool containsOrderById(const common::OrderID &id) const
Checks if an order exists in the order manager.
Definition OrderManager.cpp:55
OrderManager()=default
Default constructor.
virtual bool addOrder(std::unique_ptr< common::Order > order)
Adds an order to the order manager.
Definition OrderManager.cpp:7
uint64_t OrderID
A type alias for unique order identifiers.
Definition Types.h:134
Definition CancelOrder.h:10