CppTrader
1.0.4.0
C++ Trader
|
Market manager. More...
#include <market_manager.h>
Public Types | |
typedef std::vector< Symbol * > | Symbols |
Symbols container. More... | |
typedef std::vector< OrderBook * > | OrderBooks |
Order books container. More... | |
typedef CppCommon::HashMap< uint64_t, OrderNode *, FastHash > | Orders |
Orders container. More... | |
Public Member Functions | |
MarketManager () | |
MarketManager (MarketHandler &market_handler) | |
MarketManager (const MarketManager &)=delete | |
MarketManager (MarketManager &&)=delete | |
~MarketManager () | |
MarketManager & | operator= (const MarketManager &)=delete |
MarketManager & | operator= (MarketManager &&)=delete |
const Symbols & | symbols () const noexcept |
Get the symbols container. More... | |
const OrderBooks & | order_books () const noexcept |
Get the order books container. More... | |
const Orders & | orders () const noexcept |
Get the orders container. More... | |
const Symbol * | GetSymbol (uint32_t id) const noexcept |
Get the symbol with the given Id. More... | |
const OrderBook * | GetOrderBook (uint32_t id) const noexcept |
Get the order book for the given symbol Id. More... | |
const Order * | GetOrder (uint64_t id) const noexcept |
Get the order with the given Id. More... | |
ErrorCode | AddSymbol (const Symbol &symbol) |
Add a new symbol. More... | |
ErrorCode | DeleteSymbol (uint32_t id) |
Delete the symbol. More... | |
ErrorCode | AddOrderBook (const Symbol &symbol) |
Add a new order book. More... | |
ErrorCode | DeleteOrderBook (uint32_t id) |
Delete the order book. More... | |
ErrorCode | AddOrder (const Order &order) |
Add a new order. More... | |
ErrorCode | ReduceOrder (uint64_t id, uint64_t quantity) |
Reduce the order by the given quantity. More... | |
ErrorCode | ModifyOrder (uint64_t id, uint64_t new_price, uint64_t new_quantity) |
Modify the order. More... | |
ErrorCode | MitigateOrder (uint64_t id, uint64_t new_price, uint64_t new_quantity) |
Mitigate the order. More... | |
ErrorCode | ReplaceOrder (uint64_t id, uint64_t new_id, uint64_t new_price, uint64_t new_quantity) |
Replace the order with a similar order but different Id, price and quantity. More... | |
ErrorCode | ReplaceOrder (uint64_t id, const Order &new_order) |
Replace the order with a new one. More... | |
ErrorCode | DeleteOrder (uint64_t id) |
Delete the order. More... | |
ErrorCode | ExecuteOrder (uint64_t id, uint64_t quantity) |
Execute the order. More... | |
ErrorCode | ExecuteOrder (uint64_t id, uint64_t price, uint64_t quantity) |
Execute the order. More... | |
bool | IsMatchingEnabled () const noexcept |
Is automatic matching enabled? More... | |
void | EnableMatching () |
Enable automatic matching. More... | |
void | DisableMatching () |
Disable automatic matching. More... | |
void | Match () |
Match crossed orders in all order books. More... | |
Friends | |
class | OrderBook |
Market manager.
Market manager is used to manage the market with symbols, orders and order books.
Automatic orders matching can be enabled with EnableMatching() method or can be manually performed with Match() method.
Not thread-safe.
Definition at line 38 of file market_manager.h.
typedef std::vector<OrderBook*> CppTrader::Matching::MarketManager::OrderBooks |
Order books container.
Definition at line 46 of file market_manager.h.
typedef CppCommon::HashMap<uint64_t, OrderNode*, FastHash> CppTrader::Matching::MarketManager::Orders |
Orders container.
Definition at line 48 of file market_manager.h.
typedef std::vector<Symbol*> CppTrader::Matching::MarketManager::Symbols |
Symbols container.
Definition at line 44 of file market_manager.h.
|
inline |
Definition at line 12 of file market_manager.inl.
|
inline |
Definition at line 17 of file market_manager.inl.
|
delete |
|
delete |
CppTrader::Matching::MarketManager::~MarketManager | ( | ) |
Definition at line 16 of file market_manager.cpp.
Add a new order.
order | - Order to add |
Definition at line 135 of file market_manager.cpp.
Add a new order book.
symbol | - Symbol of the order book to add |
Definition at line 82 of file market_manager.cpp.
Add a new symbol.
symbol | - Symbol to add |
Definition at line 36 of file market_manager.cpp.
ErrorCode CppTrader::Matching::MarketManager::DeleteOrder | ( | uint64_t | id | ) |
Delete the order.
id | - Order Id |
Definition at line 815 of file market_manager.cpp.
ErrorCode CppTrader::Matching::MarketManager::DeleteOrderBook | ( | uint32_t | id | ) |
Delete the order book.
id | - Symbol Id of the order book |
Definition at line 114 of file market_manager.cpp.
ErrorCode CppTrader::Matching::MarketManager::DeleteSymbol | ( | uint32_t | id | ) |
Delete the symbol.
id | - Symbol Id |
Definition at line 61 of file market_manager.cpp.
|
inline |
Disable automatic matching.
Definition at line 214 of file market_manager.h.
|
inline |
Enable automatic matching.
Definition at line 212 of file market_manager.h.
ErrorCode CppTrader::Matching::MarketManager::ExecuteOrder | ( | uint64_t | id, |
uint64_t | price, | ||
uint64_t | quantity | ||
) |
ErrorCode CppTrader::Matching::MarketManager::ExecuteOrder | ( | uint64_t | id, |
uint64_t | quantity | ||
) |
|
inlinenoexcept |
Get the order with the given Id.
id | - Order Id |
Definition at line 44 of file market_manager.inl.
|
inlinenoexcept |
Get the order book for the given symbol Id.
id | - Symbol Id of the order book |
Definition at line 39 of file market_manager.inl.
|
inlinenoexcept |
Get the symbol with the given Id.
id | - Symbol Id |
Definition at line 34 of file market_manager.inl.
|
inlinenoexcept |
Is automatic matching enabled?
Definition at line 210 of file market_manager.h.
void CppTrader::Matching::MarketManager::Match | ( | ) |
Match crossed orders in all order books.
Method will match all crossed orders in each order book. Buy orders will be matched with sell orders at arbitrage price starting from the top of the book. Matched orders will be executed with deleted form the order book. After the matching operation each order book will have the best bid price guarantied less than the best ask price!
Definition at line 1059 of file market_manager.cpp.
ErrorCode CppTrader::Matching::MarketManager::MitigateOrder | ( | uint64_t | id, |
uint64_t | new_price, | ||
uint64_t | new_quantity | ||
) |
Mitigate the order.
The in-flight mitigation functionality prevents an order from being filled for a quantity greater than the quantity requested by the user. It protects from the risk of a resting order being filled between the time an order modification is submitted and the time the order modification is processed and applied to the order.
Order new quantity will be calculated in a following way:
Definition at line 562 of file market_manager.cpp.
ErrorCode CppTrader::Matching::MarketManager::ModifyOrder | ( | uint64_t | id, |
uint64_t | new_price, | ||
uint64_t | new_quantity | ||
) |
Modify the order.
Order new quantity will be calculated in a following way:
Definition at line 557 of file market_manager.cpp.
|
delete |
|
delete |
|
inlinenoexcept |
Get the order books container.
Definition at line 62 of file market_manager.h.
|
inlinenoexcept |
Get the orders container.
Definition at line 64 of file market_manager.h.
ErrorCode CppTrader::Matching::MarketManager::ReduceOrder | ( | uint64_t | id, |
uint64_t | quantity | ||
) |
Reduce the order by the given quantity.
Definition at line 452 of file market_manager.cpp.
Replace the order with a new one.
Definition at line 804 of file market_manager.cpp.
ErrorCode CppTrader::Matching::MarketManager::ReplaceOrder | ( | uint64_t | id, |
uint64_t | new_id, | ||
uint64_t | new_price, | ||
uint64_t | new_quantity | ||
) |
|
inlinenoexcept |
Get the symbols container.
Definition at line 60 of file market_manager.h.
|
friend |
Definition at line 40 of file market_manager.h.