Orderbook Simulation
OrderbookSim is a C++ application simulating a financial market order book. It efficiently manages and matches buy and sell orders while calculating the Volume-Weighted Average Price (VWAP).
OrderDetail.hpp
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <chrono>
13 #include "OrderType.hpp"
14 #include "Side.hpp"
15 #include "Usings.hpp"
16 #include "Constants.hpp"
17 
18 using timeChrono = std::chrono::system_clock::time_point;
19 
28 class OrderDetail {
29 private:
30  OrderType _type;
31  OrderId _id;
32  Side _side;
33  Price _price;
34  Quantity _quantity;
35  timeChrono _time;
36 
37 public:
50  OrderDetail(OrderType type, OrderId id, Side side, Price price, Quantity qty)
51  : _type{ type }, _id{ id }, _side{ side }, _price{ price }, _quantity{ qty } {
52  _time = std::chrono::system_clock::now();
53  }
54 
58  OrderDetail() = default;
59 
65  std::string getOrderType() const;
66 
72  OrderType OrderType() const;
73 
79  OrderId getOrderId() const;
80 
86  std::string getSide() const;
87 
93  Side Side() const;
94 
100  Price getPrice() const;
101 
107  Quantity getQuantity() const;
108 
114  std::string getTime() const;
115 
123  void setQuantity(Quantity newValue);
124 };
std::chrono::system_clock::time_point timeChrono
Definition: MatchedOrderDetails.hpp:20
Defines the OrderType enum and related utility functions for handling different order types.
OrderType
Specifies the different types of orders that can be used in a trading system.
Definition: OrderType.hpp:18
Defines the Side enum for representing order sides (buy or sell) and utility functions.
Side
Represents the side of an order in a trading system (either buy or sell).
Definition: Side.hpp:16
Defines type aliases commonly used in the trading system.
std::int32_t Price
Represents the price of an order or trade.
Definition: Usings.hpp:21
std::uint32_t Quantity
Represents the quantity or volume of assets in an order or trade.
Definition: Usings.hpp:29
std::uint64_t OrderId
Represents a unique identifier for an order.
Definition: Usings.hpp:37
Stores details of an individual order in the orderbook.
Definition: OrderDetail.hpp:28
OrderId getOrderId() const
Retrieves the unique identifier of the order.
Definition: OrderDetail.cpp:38
Quantity getQuantity() const
Retrieves the quantity of the order.
Definition: OrderDetail.cpp:74
Price getPrice() const
Retrieves the price of the order.
Definition: OrderDetail.cpp:65
OrderType OrderType() const
Retrieves the order type as an enum value.
Definition: OrderDetail.cpp:29
std::string getTime() const
Retrieves the timestamp of the order in a string format.
Definition: OrderDetail.cpp:83
std::string getSide() const
Retrieves the side (buy/sell) of the order as a string.
Definition: OrderDetail.cpp:47
OrderDetail(OrderType type, OrderId id, Side side, Price price, Quantity qty)
Constructs an OrderDetail with specified parameters.
Definition: OrderDetail.hpp:50
void setQuantity(Quantity newValue)
Sets a new quantity for the order.
Definition: OrderDetail.cpp:99
std::string getOrderType() const
Retrieves the order type as a string.
Definition: OrderDetail.cpp:20
OrderDetail()=default
Default constructor.
Side Side() const
Retrieves the side (buy/sell) of the order as an enum value.
Definition: OrderDetail.cpp:56