BetaTrader
A HFT Eco-System
Loading...
Searching...
No Matches
Order.h
Go to the documentation of this file.
1//
2// Created by sujal on 21-10-2025.
3//
4
5#pragma once
6#include "Time.h"
7#include "Types.h"
8#include <string> // Include for std::string
9
10namespace common {
19 class Order {
20 public:
35 Order(const OrderID clientOrderId, const OrderID coreOrderId, const Symbol symbol, ClientID client,
36 std::string senderCompID, // New parameter
37 const OrderSide side, const OrderType type,
38 const TimeInForce timeInForce, const Quantity quantity,
39 const Price price, const Timestamp ts)
40 : mClientOrderId(clientOrderId), mCoreOrderId(coreOrderId), mSymbol(symbol), mClientId(std::move(client)),
41 mSenderCompID(std::move(senderCompID)), // Initialize new member
42 mOrderSide(side), mOrderType(type), mTimeInForce(timeInForce),
43 mOriginalQuantity(quantity), mRemainingQuantity(quantity),
44 mPrice(price), mTimestamp(ts),
46 {}
47
48 public:
50 [[nodiscard]] const OrderID& getId() const
51 {
52 return mCoreOrderId;
53 }
55 [[nodiscard]] const OrderID& getClientOrderId() const
56 {
57 return mClientOrderId;
58 }
60 [[nodiscard]] const Symbol& getSymbol() const { return mSymbol; }
62 [[nodiscard]] const ClientID& getClientId() const { return mClientId; }
64 [[nodiscard]] const std::string& getSenderCompID() const { return mSenderCompID; } // New getter
66 [[nodiscard]] OrderSide getSide() const { return mOrderSide; }
68 [[nodiscard]] Price getPrice() const { return mPrice; }
70 [[nodiscard]] Timestamp getTimestamp() const { return mTimestamp; }
72 [[nodiscard]] OrderStatus getStatus() const { return mOrderStatus; }
74 [[nodiscard]] OrderType getOrderType() const { return mOrderType; }
76 [[nodiscard]] TimeInForce getTimeInForce() const
77 {
78 return mTimeInForce;
79 }
81 [[nodiscard]] Quantity getOriginalQuantity() const
82 {
83 return mOriginalQuantity;
84 }
86 [[nodiscard]] Quantity getRemainingQuantity() const
87 {
88 return mRemainingQuantity;
89 }
90
92 void setClientOrderId(const OrderID id) { mClientOrderId = id; }
94 void setCoreOrderId(const OrderID id) { mCoreOrderId = id; }
97 {
99 }
101 void setStatus(const OrderStatus status) { mOrderStatus = status; }
103 void setPrice(const Price price) { mPrice = price; }
106 {
107 mOriginalQuantity = qty;
108 mRemainingQuantity = qty;
109 }
110
112 void setTimestamp(const Timestamp ts) { mTimestamp = ts; }
113
114 private:
119 std::string mSenderCompID;
125
128
130 };
131} // namespace common
Represents a single trading order in the system.
Definition Order.h:19
Price mPrice
The price of the order.
Definition Order.h:126
Quantity mRemainingQuantity
The quantity of the order that has not yet been filled.
Definition Order.h:124
Quantity getOriginalQuantity() const
Gets the original quantity of the order.
Definition Order.h:81
void setTimestamp(const Timestamp ts)
Sets the timestamp of the order.
Definition Order.h:112
TimeInForce getTimeInForce() const
Gets the time in force of the order.
Definition Order.h:76
TimeInForce mTimeInForce
The time in force of the order.
Definition Order.h:122
void setStatus(const OrderStatus status)
Sets the status of the order.
Definition Order.h:101
OrderSide mOrderSide
The side of the order (Buy or Sell).
Definition Order.h:120
OrderSide getSide() const
Gets the order side (Buy/Sell).
Definition Order.h:66
Symbol mSymbol
Financial instrument symbol.
Definition Order.h:117
OrderType getOrderType() const
Gets the order type (Limit/Market).
Definition Order.h:74
Quantity getRemainingQuantity() const
Gets the remaining quantity of the order.
Definition Order.h:86
const OrderID & getId() const
Gets the order's core-provided identifier. This is the primary ID for internal tracking.
Definition Order.h:50
OrderStatus mOrderStatus
The current status of the order.
Definition Order.h:129
Timestamp mTimestamp
The timestamp of when the order was created.
Definition Order.h:127
Price getPrice() const
Gets the order price.
Definition Order.h:68
Timestamp getTimestamp() const
Gets the order creation timestamp.
Definition Order.h:70
Quantity mOriginalQuantity
The original quantity of the order.
Definition Order.h:123
void setRemainingQuantity(const Quantity qty)
Sets the remaining quantity of the order.
Definition Order.h:96
void setPrice(const Price price)
Sets the price of the order.
Definition Order.h:103
void setCoreOrderId(const OrderID id)
Sets the order's core-provided identifier.
Definition Order.h:94
const std::string & getSenderCompID() const
Gets the SenderCompID, identifying the actual trader.
Definition Order.h:64
const ClientID & getClientId() const
Gets the client's identifier (session ID).
Definition Order.h:62
Order(const OrderID clientOrderId, const OrderID coreOrderId, const Symbol symbol, ClientID client, std::string senderCompID, const OrderSide side, const OrderType type, const TimeInForce timeInForce, const Quantity quantity, const Price price, const Timestamp ts)
Constructs a new Order object.
Definition Order.h:35
const OrderID & getClientOrderId() const
Gets the order's client-provided identifier.
Definition Order.h:55
OrderID mCoreOrderId
Unique identifier for the order given by core.
Definition Order.h:116
std::string mSenderCompID
SenderCompID from the FIX message, identifying the actual trader.
Definition Order.h:119
void setClientOrderId(const OrderID id)
Sets the order's client-provided identifier.
Definition Order.h:92
OrderType mOrderType
The type of the order (Limit or Market).
Definition Order.h:121
ClientID mClientId
Identifier of the client placing the order (session ID).
Definition Order.h:118
void setOriginalQuantity(const Quantity qty)
Sets the original and remaining quantity of the order.
Definition Order.h:105
OrderStatus getStatus() const
Gets the current status of the order.
Definition Order.h:72
const Symbol & getSymbol() const
Gets the financial instrument symbol.
Definition Order.h:60
OrderID mClientOrderId
Unique identifier for the order given by client.
Definition Order.h:115
Defines type aliases for FIX protocol fields.
Definition Instrument.h:11
std::chrono::system_clock::time_point Timestamp
A type alias for std::chrono::system_clock::time_point.
Definition Time.h:15
double Price
A type alias for price values.
Definition Types.h:130
Instrument
Represents the financial instruments available for trading.
Definition Instrument.h:17
OrderType
Represents the execution logic of an order.
Definition Types.h:26
uint64_t OrderID
A type alias for unique order identifiers.
Definition Types.h:134
uint64_t Quantity
A type alias for quantity values.
Definition Types.h:132
TimeInForce
Guides How long the order is in the system.
Definition Types.h:54
std::string ClientID
A type alias for client identifiers.
Definition Types.h:140
OrderStatus
Represents the lifecycle of an order.
Definition Types.h:41
@ New
The order has been created but not yet matched.
OrderSide
Represents the side of an order (Buy or Sell).
Definition Types.h:17