24 ONIXS_HANDLER_NAMESPACE_BEGIN
59 level.removeOrderId(order.
id_);
99 size_t maxAggregatedPriceLevelsCount,
102 OrderDepthBook(maxAggregatedPriceLevelsCount, bookDepth, poolManager),
103 bookDepth_(bookDepth),
111 size_t OrderBookInternal::doDepth()
const 116 const PriceLevels& OrderBookInternal::doAsks()
const 118 return OrderDepthBook::askOrders().levels().levels();
121 const PriceLevels& OrderBookInternal::doBids()
const 123 return OrderDepthBook::bidOrders().levels().levels();
126 bool OrderBookInternal::doBestAsk(
Price& price,
Quantity& quantity)
const 133 price = levels[0].price();
134 quantity = levels[0].quantity();
139 bool OrderBookInternal::doBestBid(
Price& price,
Quantity& quantity)
const 146 price = levels[0].price();
147 quantity = levels[0].quantity();
152 OrderBookId OrderBookInternal::doOrderBookId()
const 157 void* OrderBookInternal::operator
new (std::size_t)
159 throw std::bad_alloc();
162 void OrderBookInternal::operator
delete (
void*)
166 void* OrderBookInternal::operator
new (std::size_t,
void* p)
171 void OrderBookInternal::operator
delete (
void*,
void*)
182 const bool hasBestAsk = bestAsk(bestAskPrice, bestAskQuantity);
186 const bool hasBestBid = bestBid(bestBidPrice, bestBidQuantity);
192 void OrderBookInternal::checkAsksSanity()
const 198 const bool hasBestAsk = bestAsk(bestAskPrice, bestAskQuantity);
200 if(asksLevels.size() == 0)
206 if(asksLevels.at(0).price() != bestAskPrice)
209 for(PriceLevels::const_iterator pos = asksLevels.begin(), end = asksLevels.end(); pos != end; ++pos)
211 if(pos->quantity() <= 0)
215 for(
size_t i = 1; i < asksLevels.size(); ++i)
221 for(
size_t i = 1; i < asksLevels.size(); ++i)
223 if(asksLevels.at(i).price() !=
Price(0))
225 if(asksLevels.at(i - 1).price() >= asksLevels.at(i).price())
231 void OrderBookInternal::checkBidsSanity()
const 237 const bool hasBestBid = bestBid(bestBidPrice, bestBidQuantity);
239 if(bidsLevels.size() == 0)
245 if(bidsLevels.at(0).price() != bestBidPrice)
248 for(PriceLevels::const_iterator pos = bidsLevels.begin(), end = bidsLevels.end(); pos != end; ++pos)
250 if(pos->quantity() <= 0)
254 for(
size_t i = 1; i < bidsLevels.size(); ++i)
260 for(
size_t i = 1; i < bidsLevels.size(); ++i)
262 if(bidsLevels.at(i).price() !=
Price(0))
264 if(bidsLevels.at(i - 1).price() <= bidsLevels.at(i).price())
272 return OrderDepthBook::askOrders();
277 return OrderDepthBook::askOrders();
282 return OrderDepthBook::bidOrders();
287 return OrderDepthBook::bidOrders();
292 return OrderDepthBook::remove(orderId);
297 OrderDepthBook::clear();
303 poolPtr_(poolSize_, 0),
304 allocator_(&poolPtr_.front(), poolSize_)
328 for(PriceLevels::const_iterator i = asks.begin(), end = asks.end(); i < end; ++i)
330 boost::hash_combine(seed, i->quantity());
331 boost::hash_combine(seed, i->numberOfOrders());
332 boost::hash_combine(seed, (Int64)i->price().value());
336 for(PriceLevels::const_iterator i = bids.begin(), end = bids.end(); i < end; ++i)
338 boost::hash_combine(seed, i->quantity());
339 boost::hash_combine(seed, i->numberOfOrders());
340 boost::hash_combine(seed, (Int64)i->price().value());
347 ONIXS_HANDLER_NAMESPACE_END
size_t hash_value(OrderBookInternal const &book)
UInt64 OrderId
Alias for OrderId type.
virtual ~OrderBookInternal()
static bool isOrderAffectsPriceLevel(const Order &order)
const PriceLevels & bids() const
Returns a set of ascending ask prices for the given security.
static void removeOrder(const Order &order, PriceLevel &level)
OrderBookInternal(const OrderBookId &id, size_t bookDepth, size_t maxAggregatedPriceLevelsCount=(size_t)-1, const PoolManagerPtr &poolManager=PoolManagerPtr())
Encapsulates price level concept.
const PriceLevels & asks() const
Returns a set of descending bid prices for the given security.
UInt64 Quantity
Alias for Quantity type.
BidFullOrderDepthMap & bidOrders()
UInt32 OrderBookId
Alias for Security Id type.
PriceLevelCollections::Array PriceLevels
Sequence of price levels.
OrderDepthBook::BidFullOrderDepthMap BidFullOrderDepthMap
const OrderId & getOrderId(const Order &order)
OrderBookAllocator(size_t objectsAmount)
void remove(const OrderId &orderId)
OrderDepthBook::AskFullOrderDepthMap AskFullOrderDepthMap
const Price & getPrice(const PriceLevel &level)
const OrderInfos & orders() const
orders ids for a given level
Quantity quantity() const
Quantify for the given price.
AskFullOrderDepthMap & askOrders()
OnixS::HandlerCore::MarketData::FullOrderDepthBook< PriceLevel, Order, OrderId, Price, BaseFullOrderDepthBook > OrderDepthBook
static void addOrder(const Order &order, PriceLevel &level)
OrderDepthBook::PoolManagerPtr PoolManagerPtr
bool isValid(const PriceLevel &level)
Quantity numberOfOrders() const
Total number of orders of given price.