9 #ifndef CPPTRADER_MATCHING_ORDER_H
10 #define CPPTRADER_MATCHING_ORDER_H
14 #include "containers/list.h"
15 #include "utility/iostream.h"
39 template <
class TOutputStream>
91 template <
class TOutputStream>
117 template <
class TOutputStream>
201 Order(uint64_t
id, uint32_t symbol,
OrderType type,
OrderSide side, uint64_t price, uint64_t stop_price, uint64_t quantity,
203 uint64_t max_visible_quantity = std::numeric_limits<uint64_t>::max(),
204 uint64_t slippage = std::numeric_limits<uint64_t>::max(),
205 int64_t trailing_distance = 0,
206 int64_t trailing_step = 0) noexcept;
214 template <class TOutputStream>
215 friend TOutputStream& operator<<(TOutputStream& stream, const
Order& order);
247 bool IsIceberg() const noexcept {
return MaxVisibleQuantity < std::numeric_limits<uint64_t>::max(); }
250 bool IsSlippage() const noexcept {
return Slippage < std::numeric_limits<uint64_t>::max(); }
256 static
Order Market(uint64_t
id, uint32_t symbol,
OrderSide side, uint64_t quantity, uint64_t slippage = std::numeric_limits<uint64_t>::max()) noexcept;
258 static
Order BuyMarket(uint64_t
id, uint32_t symbol, uint64_t quantity, uint64_t slippage = std::numeric_limits<uint64_t>::max()) noexcept;
260 static
Order SellMarket(uint64_t
id, uint32_t symbol, uint64_t quantity, uint64_t slippage = std::numeric_limits<uint64_t>::max()) noexcept;
286 static
Order TrailingBuyStop(uint64_t
id, uint32_t symbol, uint64_t stop_price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step = 0,
OrderTimeInForce tif =
OrderTimeInForce::GTC, uint64_t slippage = std::numeric_limits<uint64_t>::max()) noexcept;
288 static
Order TrailingSellStop(uint64_t
id, uint32_t symbol, uint64_t stop_price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step = 0,
OrderTimeInForce tif =
OrderTimeInForce::GTC, uint64_t slippage = std::numeric_limits<uint64_t>::max()) noexcept;
291 static
Order TrailingStopLimit(uint64_t
id, uint32_t symbol,
OrderSide side, uint64_t stop_price, uint64_t price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step = 0,
OrderTimeInForce tif =
OrderTimeInForce::GTC, uint64_t max_visible_quantity = std::numeric_limits<uint64_t>::max()) noexcept;
293 static
Order TrailingBuyStopLimit(uint64_t
id, uint32_t symbol, uint64_t stop_price, uint64_t price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step = 0,
OrderTimeInForce tif =
OrderTimeInForce::GTC, uint64_t max_visible_quantity = std::numeric_limits<uint64_t>::max()) noexcept;
295 static
Order TrailingSellStopLimit(uint64_t
id, uint32_t symbol, uint64_t stop_price, uint64_t price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step = 0,
OrderTimeInForce tif =
OrderTimeInForce::GTC, uint64_t max_visible_quantity = std::numeric_limits<uint64_t>::max()) noexcept;
OrderTimeInForce
Order Time in Force.
@ IOC
Immediate-Or-Cancel.
@ GTC
Good-Till-Cancelled.
TOutputStream & operator<<(TOutputStream &stream, ErrorCode error)
C++ Trader project definitions.
bool IsHidden() const noexcept
Is the 'Hidden' order?
bool IsFOK() const noexcept
Is the 'Fill-Or-Kill' order?
uint64_t VisibleQuantity() const noexcept
Order visible quantity.
ErrorCode Validate() const noexcept
Validate order parameters.
bool IsIceberg() const noexcept
Is the 'Iceberg' order?
bool IsStopLimit() const noexcept
Is the stop-limit order?
static Order SellLimit(uint64_t id, uint32_t symbol, uint64_t price, uint64_t quantity, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t max_visible_quantity=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new sell limit order.
static Order BuyStopLimit(uint64_t id, uint32_t symbol, uint64_t stop_price, uint64_t price, uint64_t quantity, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t max_visible_quantity=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new buy stop-limit order.
static Order BuyMarket(uint64_t id, uint32_t symbol, uint64_t quantity, uint64_t slippage=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new buy market order.
static Order TrailingBuyStop(uint64_t id, uint32_t symbol, uint64_t stop_price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step=0, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t slippage=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new trailing buy stop order.
static Order Stop(uint64_t id, uint32_t symbol, OrderSide side, uint64_t stop_price, uint64_t quantity, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t slippage=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new stop order.
bool IsAON() const noexcept
Is the 'All-Or-None' order?
OrderSide Side
Order side.
uint64_t Price
Order price.
uint64_t MaxVisibleQuantity
Order max visible quantity.
bool IsTrailingStop() const noexcept
Is the trailing stop order?
int64_t TrailingStep
Order trailing step.
bool IsSlippage() const noexcept
Is the order have slippage?
uint64_t ExecutedQuantity
Order executed quantity.
static Order TrailingStop(uint64_t id, uint32_t symbol, OrderSide side, uint64_t stop_price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step=0, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t slippage=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new trailing stop order.
static Order Market(uint64_t id, uint32_t symbol, OrderSide side, uint64_t quantity, uint64_t slippage=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new market order.
static Order SellStopLimit(uint64_t id, uint32_t symbol, uint64_t stop_price, uint64_t price, uint64_t quantity, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t max_visible_quantity=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new sell stop-limit order.
bool IsGTC() const noexcept
Is the 'Good-Till-Cancelled' order?
static Order TrailingStopLimit(uint64_t id, uint32_t symbol, OrderSide side, uint64_t stop_price, uint64_t price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step=0, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t max_visible_quantity=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new trailing stop-limit order.
bool IsBuy() const noexcept
Is the order with buy side?
static Order StopLimit(uint64_t id, uint32_t symbol, OrderSide side, uint64_t stop_price, uint64_t price, uint64_t quantity, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t max_visible_quantity=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new stop-limit order.
static Order Limit(uint64_t id, uint32_t symbol, OrderSide side, uint64_t price, uint64_t quantity, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t max_visible_quantity=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new limit order.
uint64_t LeavesQuantity
Order leaves quantity.
uint64_t StopPrice
Order stop price.
bool IsLimit() const noexcept
Is the limit order?
OrderType Type
Order type.
static Order SellMarket(uint64_t id, uint32_t symbol, uint64_t quantity, uint64_t slippage=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new sell market order.
OrderTimeInForce TimeInForce
Time in Force.
static Order SellStop(uint64_t id, uint32_t symbol, uint64_t stop_price, uint64_t quantity, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t slippage=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new sell stop order.
uint64_t HiddenQuantity() const noexcept
Order hidden quantity.
static Order BuyLimit(uint64_t id, uint32_t symbol, uint64_t price, uint64_t quantity, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t max_visible_quantity=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new buy limit order.
bool IsMarket() const noexcept
Is the market order?
int64_t TrailingDistance
Order trailing distance to market.
static Order TrailingBuyStopLimit(uint64_t id, uint32_t symbol, uint64_t stop_price, uint64_t price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step=0, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t max_visible_quantity=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new trailing buy stop-limit order.
bool IsIOC() const noexcept
Is the 'Immediate-Or-Cancel' order?
bool IsStop() const noexcept
Is the stop order?
uint32_t SymbolId
Symbol Id.
bool IsTrailingStopLimit() const noexcept
Is the trailing stop-limit order?
static Order BuyStop(uint64_t id, uint32_t symbol, uint64_t stop_price, uint64_t quantity, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t slippage=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new buy stop order.
uint64_t Slippage
Market order slippage.
static Order TrailingSellStop(uint64_t id, uint32_t symbol, uint64_t stop_price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step=0, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t slippage=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new trailing sell stop order.
uint64_t Quantity
Order quantity.
bool IsSell() const noexcept
Is the order with sell side?
static Order TrailingSellStopLimit(uint64_t id, uint32_t symbol, uint64_t stop_price, uint64_t price, uint64_t quantity, int64_t trailing_distance, int64_t trailing_step=0, OrderTimeInForce tif=OrderTimeInForce::GTC, uint64_t max_visible_quantity=std::numeric_limits< uint64_t >::max()) noexcept
Prepare a new trailing sell stop-limit order.
OrderNode(const OrderNode &) noexcept=default
OrderNode(OrderNode &&) noexcept=default