libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
|
A simple implementation of a price/time limit order book. More...
#include <order_book.hpp>
Classes | |
struct | cheapest_orders_by_time_t |
struct | cheapest_t |
class | most_expensive_by_time_t |
struct | most_expensive_t |
Public Types | |
using | msg_details_t = MsgType |
using | price_t = typename msg_details_t::Price_t |
using | quantity_t = typename msg_details_t::Quantity_t |
using | side_t = typename msg_details_t::Side |
using | symbol_t = typename msg_details_t::SecurityID_t |
using | order_t = typename msg_details_t::NewOrder_t |
using | execution_t = typename msg_details_t::ExecutionReport |
using | lock_traits = libjmmcg::ppd::api_lock_traits< libjmmcg::ppd::platform_api, libjmmcg::ppd::heavyweight_threading > |
using | exception_type = lock_traits::exception_type |
using | trades_t = std::vector< execution_t > |
using | orders_by_time = std::list< internal_order > |
Public Member Functions | |
order_book () | |
~order_book () | |
bool | empty () const noexcept(true) |
bool | is_crossed () const noexcept(true) |
price_t | agreed_spread (symbol_t const &symbol) const noexcept(true) |
void | place (order_t const &order) noexcept(false) |
Place the requested order in the book. More... | |
void | cancel (order_t const &order) noexcept(false) |
Remove the specified order from the order book. More... | |
trades_t | match () |
Return all possible trades, also uncrossing the order book. More... | |
Friends | |
template<class MsgTypes1 > | |
std::ostream & | operator<< (std::ostream &os, order_book< MsgTypes1 > const &o) |
A simple implementation of a price/time limit order book.
Exchange matching engines use an order book to match orders from buyers and sellers.
Definition at line 45 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::exception_type = lock_traits::exception_type |
Definition at line 55 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::execution_t = typename msg_details_t::ExecutionReport |
Definition at line 53 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::lock_traits = libjmmcg::ppd::api_lock_traits<libjmmcg::ppd::platform_api, libjmmcg::ppd::heavyweight_threading> |
Definition at line 54 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::msg_details_t = MsgType |
Definition at line 47 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::order_t = typename msg_details_t::NewOrder_t |
Definition at line 52 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::orders_by_time = std::list<internal_order> |
We push_back(), so orders towards the beginning of the collection are older than those towards the end.
Definition at line 83 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::price_t = typename msg_details_t::Price_t |
Definition at line 48 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::quantity_t = typename msg_details_t::Quantity_t |
Definition at line 49 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::side_t = typename msg_details_t::Side |
Definition at line 50 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::symbol_t = typename msg_details_t::SecurityID_t |
Definition at line 51 of file order_book.hpp.
using isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::trades_t = std::vector<execution_t> |
Definition at line 77 of file order_book.hpp.
|
inline |
Definition at line 252 of file order_book_impl.hpp.
|
inline |
Definition at line 257 of file order_book_impl.hpp.
|
inlinenoexcept |
Algorithmic complexity: O(n) where n is the total number of orders in all the books.
Definition at line 281 of file order_book_impl.hpp.
|
inlinenoexcept |
Remove the specified order from the order book.
Algorithmic complexity: O(n^2) where n is the total number of orders in all the books.
Definition at line 321 of file order_book_impl.hpp.
References isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::empty().
|
inlinenoexcept |
Algorithmic complexity: O(1)
Definition at line 262 of file order_book_impl.hpp.
Referenced by isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::cancel(), and isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::match().
|
inlinenoexcept |
Algorithmic complexity: O(num_symbols*n) where num_symbols is the total number of symbols that have been placed and n is the total number of orders in all the books.
Definition at line 268 of file order_book_impl.hpp.
Referenced by isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::match().
|
inline |
Return all possible trades, also uncrossing the order book.
After calling place() this function may need to be called as the order book may be crossed and thus potential executions that only match() can discover.
Algorithmic complexity: O(num_executions*num_symbols*log(n)) where:
Definition at line 343 of file order_book_impl.hpp.
References isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::empty(), and isimud::ISIMUD_VER_NAMESPACE::order_book< MsgType >::is_crossed().
|
inlinenoexcept |
Place the requested order in the book.
This may leave the order book in a crossed state, i.e. there may be available trades, so match() may have to be called after calling place().
Algorithmic complexity: O(log(n)) where n is the total number of orders in all the books.
Definition at line 294 of file order_book_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::info::function::add_arg().
|
friend |
Algorithmic complexity: O(n) where n is the total number of orders in all the books.