CppTrader  1.0.4.0
C++ Trader
Classes | Enumerations | Functions
CppTrader::Matching Namespace Reference

Matching engine definitions. More...

Classes

class  FastHash
 Fast hash helper. More...
 
struct  Level
 Price level. More...
 
struct  LevelNode
 Price level node. More...
 
struct  LevelUpdate
 Price level update. More...
 
class  MarketHandler
 Market handler class. More...
 
class  MarketManager
 Market manager. More...
 
struct  Order
 Order. More...
 
struct  OrderNode
 Order node. More...
 
class  OrderBook
 Order book. More...
 
struct  Symbol
 Symbol. More...
 

Enumerations

enum class  ErrorCode : uint8_t {
  OK , SYMBOL_DUPLICATE , SYMBOL_NOT_FOUND , ORDER_BOOK_DUPLICATE ,
  ORDER_BOOK_NOT_FOUND , ORDER_DUPLICATE , ORDER_NOT_FOUND , ORDER_ID_INVALID ,
  ORDER_TYPE_INVALID , ORDER_PARAMETER_INVALID , ORDER_QUANTITY_INVALID
}
 Error code. More...
 
enum class  LevelType : uint8_t { BID , ASK }
 Price level type. More...
 
enum class  OrderSide : uint8_t { BUY , SELL }
 Order side. More...
 
enum class  OrderType : uint8_t {
  MARKET , LIMIT , STOP , STOP_LIMIT ,
  TRAILING_STOP , TRAILING_STOP_LIMIT
}
 Order type. More...
 
enum class  OrderTimeInForce : uint8_t { GTC , IOC , FOK , AON }
 Order Time in Force. More...
 
enum class  UpdateType : uint8_t { NONE , ADD , UPDATE , DELETE }
 Update type. More...
 

Functions

template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, ErrorCode error)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, LevelType type)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, const Level &level)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, const LevelUpdate &update)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, OrderSide side)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, OrderType type)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, OrderTimeInForce tif)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, const Order &order)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, const OrderBook &order_book)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, const Symbol &symbol)
 
template<class TOutputStream >
TOutputStream & operator<< (TOutputStream &stream, UpdateType type)
 

Detailed Description

Matching engine definitions.

Enumeration Type Documentation

◆ ErrorCode

enum CppTrader::Matching::ErrorCode : uint8_t
strong

Error code.

Enumerator
OK 
SYMBOL_DUPLICATE 
SYMBOL_NOT_FOUND 
ORDER_BOOK_DUPLICATE 
ORDER_BOOK_NOT_FOUND 
ORDER_DUPLICATE 
ORDER_NOT_FOUND 
ORDER_ID_INVALID 
ORDER_TYPE_INVALID 
ORDER_PARAMETER_INVALID 
ORDER_QUANTITY_INVALID 
Examples
matching_engine.cpp.

Definition at line 20 of file errors.h.

◆ LevelType

enum CppTrader::Matching::LevelType : uint8_t
strong

Price level type.

Enumerator
BID 
ASK 

Definition at line 21 of file level.h.

◆ OrderSide

enum CppTrader::Matching::OrderSide : uint8_t
strong

Order side.

Possible values:

  • Buy - Buy side is the side of orders made up of investing institutions such as mutual funds, pension funds and insurance firms that tend to buy large portions of securities for money-management purposes.
  • Sell - The opposite side to buy made up of investing institutions that tend to sell large portions of securities for money-management purposes.
Enumerator
BUY 
SELL 

Definition at line 33 of file order.h.

◆ OrderTimeInForce

Order Time in Force.

Possible values:

  • Good-Till-Cancelled (GTC) - A GTC order is an order to buy or sell a stock that lasts until the order is completed or cancelled.
  • Immediate-Or-Cancel (IOC) - An IOC order is an order to buy or sell a stock that must be executed immediately. Any portion of the order that cannot be filled immediately will be cancelled.
  • Fill-Or-Kill (FOK) - An FOK order is an order to buy or sell a stock that must be executed immediately in its entirety; otherwise, the entire order will be cancelled (i.e., no partial execution of the order is allowed).
  • All-Or-None (AON) - An All-Or-None (AON) order is an order to buy or sell a stock that must be executed in its entirety, or not executed at all. AON orders that cannot be executed immediately remain active until they are executed or cancelled.
Enumerator
GTC 

Good-Till-Cancelled.

IOC 

Immediate-Or-Cancel.

FOK 

Fill-Or-Kill.

AON 

All-Or-None.

Definition at line 109 of file order.h.

◆ OrderType

enum CppTrader::Matching::OrderType : uint8_t
strong

Order type.

Possible values:

  • Market order - A market order is an order to buy or sell a stock at the best available price. Generally, this type of order will be executed immediately. However, the price at which a market order will be executed is not guaranteed. It is important for investors to remember that the last-traded price is not necessarily the price at which a market order will be executed. In fast-moving markets, the price at which a market order will execute often deviates from the last-traded price or "real time" quote.
  • Limit order - A limit order is an order to buy or sell a stock at a specific price or better. A buy limit order can only be executed at the limit price or lower, and a sell limit order can only be executed at the limit price or higher. A limit order is not guaranteed to execute. A limit order can only be filled if the stock's market price reaches the limit price. While limit orders do not guarantee execution, they help ensure that an investor does not pay more than a predetermined price for a stock.
  • Stop order - A stop order, also referred to as a stop-loss order, is an order to buy or sell a stock once the price of the stock reaches a specified price, known as the stop price. When the stop price is reached, a stop order becomes a market order. A buy stop order is entered at a stop price above the current market price. Investors generally use a buy stop order to limit a loss or to protect a profit on a stock that they have sold short. A sell stop order is entered at a stop price below the current market price. Investors generally use a sell stop order to limit a loss or to protect a profit on a stock that they own.
  • Stop-limit order - A stop-limit order is an order to buy or sell a stock that combines the features of a stop order and a limit order. Once the stop price is reached, a stop-limit order becomes a limit order that will be executed at a specified price (or better). The benefit of a stop-limit order is that the investor can control the price at which the order can be executed.
  • Trailing stop order - A trailing stop order is entered with a stop parameter that creates a moving or trailing activation price, hence the name. This parameter is entered as a percentage change or actual specific amount of rise (or fall) in the security price. Trailing stop sell orders are used to maximize and protect profit as a stock's price rises and limit losses when its price falls.
  • Trailing stop-limit order - A trailing stop-limit order is similar to a trailing stop order. Instead of selling at market price when triggered, the order becomes a limit order.
Enumerator
MARKET 
LIMIT 
STOP 
STOP_LIMIT 
TRAILING_STOP 
TRAILING_STOP_LIMIT 

Definition at line 81 of file order.h.

◆ UpdateType

enum CppTrader::Matching::UpdateType : uint8_t
strong

Update type.

Enumerator
NONE 
ADD 
UPDATE 
DELETE 

Definition at line 20 of file update.h.

Function Documentation

◆ operator<<() [1/11]

template<class TOutputStream >
TOutputStream& CppTrader::Matching::operator<< ( TOutputStream &  stream,
const Level level 
)
inline

Definition at line 41 of file level.inl.

◆ operator<<() [2/11]

template<class TOutputStream >
TOutputStream& CppTrader::Matching::operator<< ( TOutputStream &  stream,
const LevelUpdate update 
)
inline

Definition at line 77 of file level.inl.

◆ operator<<() [3/11]

template<class TOutputStream >
TOutputStream& CppTrader::Matching::operator<< ( TOutputStream &  stream,
const Order order 
)
inline

Definition at line 103 of file order.inl.

◆ operator<<() [4/11]

template<class TOutputStream >
TOutputStream& CppTrader::Matching::operator<< ( TOutputStream &  stream,
const OrderBook order_book 
)
inline

Definition at line 13 of file order_book.inl.

◆ operator<<() [5/11]

template<class TOutputStream >
TOutputStream& CppTrader::Matching::operator<< ( TOutputStream &  stream,
const Symbol symbol 
)
inline

Definition at line 19 of file symbol.inl.

◆ operator<<() [6/11]

template<class TOutputStream >
TOutputStream & CppTrader::Matching::operator<< ( TOutputStream &  stream,
ErrorCode  error 
)
inline

Definition at line 13 of file errors.inl.

◆ operator<<() [7/11]

template<class TOutputStream >
TOutputStream & CppTrader::Matching::operator<< ( TOutputStream &  stream,
LevelType  type 
)
inline

Definition at line 13 of file level.inl.

◆ operator<<() [8/11]

template<class TOutputStream >
TOutputStream & CppTrader::Matching::operator<< ( TOutputStream &  stream,
OrderSide  side 
)
inline

Definition at line 13 of file order.inl.

◆ operator<<() [9/11]

template<class TOutputStream >
TOutputStream & CppTrader::Matching::operator<< ( TOutputStream &  stream,
OrderTimeInForce  tif 
)
inline

Definition at line 61 of file order.inl.

◆ operator<<() [10/11]

template<class TOutputStream >
TOutputStream & CppTrader::Matching::operator<< ( TOutputStream &  stream,
OrderType  type 
)
inline

Definition at line 31 of file order.inl.

◆ operator<<() [11/11]

template<class TOutputStream >
TOutputStream & CppTrader::Matching::operator<< ( TOutputStream &  stream,
UpdateType  type 
)
inline

Definition at line 13 of file update.inl.