12 template <
class TOutputStream>
15 stream <<
"OrderBook(Symbol=" << order_book._symbol
16 <<
"; Bids=" << order_book._bids.size()
17 <<
"; Asks=" << order_book._asks.size()
18 <<
"; BuyStop=" << order_book._buy_stop.size()
19 <<
"; SellStop=" << order_book._sell_stop.size()
20 <<
"; TrailingBuyStop=" << order_book._trailing_buy_stop.size()
21 <<
"; TrailingSellStop=" << order_book._trailing_sell_stop.size()
29 return (it != _bids.end()) ? it.operator->() :
nullptr;
35 return (it != _asks.end()) ? it.operator->() :
nullptr;
41 return (it != _buy_stop.end()) ? it.operator->() :
nullptr;
47 return (it != _sell_stop.end()) ? it.operator->() :
nullptr;
53 return (it != _trailing_buy_stop.end()) ? it.operator->() :
nullptr;
59 return (it != _trailing_sell_stop.end()) ? it.operator->() :
nullptr;
66 Levels::reverse_iterator it(&_bids, level);
68 return it.operator->();
72 Levels::iterator it(&_asks, level);
74 return it.operator->();
78 inline LevelNode* OrderBook::GetNextStopLevel(LevelNode* level) noexcept
82 Levels::reverse_iterator it(&_sell_stop, level);
84 return it.operator->();
88 Levels::iterator it(&_buy_stop, level);
90 return it.operator->();
94 inline LevelNode* OrderBook::GetNextTrailingStopLevel(LevelNode* level) noexcept
98 Levels::reverse_iterator it(&_trailing_sell_stop, level);
100 return it.operator->();
104 Levels::iterator it(&_trailing_buy_stop, level);
106 return it.operator->();
110 inline uint64_t OrderBook::GetMarketPriceBid() const noexcept
112 uint64_t matching_price = _matching_bid_price;
113 uint64_t best_price = (_best_bid !=
nullptr) ? _best_bid->
Price : 0;
114 return std::max(matching_price, best_price);
117 inline uint64_t OrderBook::GetMarketPriceAsk() const noexcept
119 uint64_t matching_price = _matching_ask_price;
120 uint64_t best_price = (_best_ask !=
nullptr) ? _best_ask->
Price : std::numeric_limits<uint64_t>::max();
121 return std::min(matching_price, best_price);
124 inline uint64_t OrderBook::GetMarketTrailingStopPriceBid() const noexcept
126 uint64_t last_price = _last_bid_price;
127 uint64_t best_price = (_best_bid !=
nullptr) ? _best_bid->
Price : 0;
128 return std::min(last_price, best_price);
131 inline uint64_t OrderBook::GetMarketTrailingStopPriceAsk() const noexcept
133 uint64_t last_price = _last_ask_price;
134 uint64_t best_price = (_best_ask !=
nullptr) ? _best_ask->
Price : std::numeric_limits<uint64_t>::max();
135 return std::max(last_price, best_price);
138 inline void OrderBook::UpdateLastPrice(
const Order& order, uint64_t price) noexcept
141 _last_bid_price = price;
143 _last_ask_price = price;
146 inline void OrderBook::UpdateMatchingPrice(
const Order& order, uint64_t price) noexcept
149 _matching_bid_price = price;
151 _matching_ask_price = price;
154 inline void OrderBook::ResetMatchingPrice() noexcept
156 _matching_bid_price = 0;
157 _matching_ask_price = std::numeric_limits<uint64_t>::max();
const LevelNode * GetAsk(uint64_t price) const noexcept
Get the order book ask price level with the given price.
const LevelNode * GetTrailingBuyStopLevel(uint64_t price) const noexcept
Get the order book trailing buy stop level with the given price.
const LevelNode * GetBid(uint64_t price) const noexcept
Get the order book bid price level with the given price.
const LevelNode * GetSellStopLevel(uint64_t price) const noexcept
Get the order book sell stop level with the given price.
const LevelNode * GetTrailingSellStopLevel(uint64_t price) const noexcept
Get the order book trailing sell stop level with the given price.
const LevelNode * GetBuyStopLevel(uint64_t price) const noexcept
Get the order book buy stop level with the given price.
TOutputStream & operator<<(TOutputStream &stream, ErrorCode error)
C++ Trader project definitions.
uint64_t Price
Level price.