OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  8.1.0
API documentation
EobiBookImpl.h
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 
20 #pragma once
21 
24 #include <OnixS/HandlerCore/OrderBook.h>
25 
26 #include <OnixS/Core/Memory/FixedBlockAllocator.h>
27 
28 
29 namespace OnixS {
30 namespace Eurex {
31 namespace MarketData {
32 namespace EOBI {
33 namespace Implementation {
34 
35 
36 struct Order
37 {
41 
42  Order();
43  Order(const OrderId& inId, const Decimal& inPrice, QuantityType inQuantity);
44  static void addOrder(const Order& order, PriceLevel& level);
45  static void removeOrder(const Order& order, PriceLevel& level);
46 };
47 
48 void addOrder(const Order& order, PriceLevel& level);
49 void removeOrder(const Order& order, PriceLevel& level);
50 const OrderId& getOrderId(const Order& order);
51 const Decimal& getPrice(const Order& order);
52 bool isOrderAffectsPriceLevel (const Order& order);
53 
54 static const size_t DefaultMaxBooksAmount = 500;
55 
57 {
58  typedef OnixS::HandlerCore::MarketData::DefaultBaseFullOrderDepthBook::BaseAskMap BaseAskMap;
59  typedef OnixS::HandlerCore::MarketData::DefaultBaseFullOrderDepthBook::BaseBidMap BaseBidMap;
60 };
61 
62 
63 typedef OnixS::HandlerCore::MarketData::FullOrderDepthBook<PriceLevel, Order, OrderId, Decimal, BaseFullOrderDepthBook> OrderDepthBook;
64 
65 
66 class OrderBookInternal : public EOBI::OrderBook, public OrderDepthBook
67 {
68 public:
69  typedef OrderDepthBook::AskFullOrderDepthMap AskFullOrderDepthMap;
70  typedef OrderDepthBook::BidFullOrderDepthMap BidFullOrderDepthMap;
71  typedef OrderDepthBook::PoolManager PoolManager;
72  typedef OrderDepthBook::PoolManagerPtr PoolManagerPtr;
73  typedef OrderDepthBook::OrderIdMap OrderIdMap;
74  typedef OrderIdMap::Map BookSide;
75 
76  using OrderBook::asks;
77  using OrderBook::bids;
78  using OrderBook::depth;
79  using OrderBook::empty;
80 
81 public:
83  (
84  const SecurityId& id,
85  size_t bookDepth,
86  size_t maxAggregatedPriceLevelsCount = (size_t)-1,
87  const PoolManagerPtr& poolManager = PoolManagerPtr()
88  );
89 
90  AskFullOrderDepthMap& askOrders();
91  const AskFullOrderDepthMap& askOrders() const;
92  BidFullOrderDepthMap& bidOrders();
93  const BidFullOrderDepthMap& bidOrders() const;
94 
95  void remove(const OrderId& orderId);
96  void clear();
97  void checkSanity() const;
98 
99  static void operator delete (void* book);
100  static void operator delete(void*, void *) {}
101 
102 private:
103  size_t doDepth() const;
104  const PriceLevels& doAsks() const;
105  const PriceLevels& doBids() const;
106  bool doBestAsk (Price& price, QuantityType& quantity) const;
107  bool doBestBid (Price& price, QuantityType& quantity) const;
108  //boost::scoped_ptr<OrderBook> doSnapshot() const;
109  SecurityId doSecurityId() const;
110 
111 private:
113  const OrderBookInternal& operator=(const OrderBookInternal&);
114 
115 private:
116  const size_t bookDepth_;
117  SecurityId id_;
118 };
119 
120 
121 class OrderBookAllocator : public boost::noncopyable
122 {
123 public:
124  explicit
125  OrderBookAllocator(size_t objectsAmount);
127  void* alloc();
128  void reset();
129 
130 private:
131  const size_t poolSize_;
132  std::vector<unsigned char> poolPtr_;
133  OnixS::FixedBlockAllocator allocator_;
134 };
135 
136 
137 size_t hash_value(OrderBookInternal const& book);
138 
139 
140 }}}}}
141 
142 
143 
144 namespace OnixS {
145 namespace HandlerCore {
146 namespace MarketData {
147 namespace Detail{
148 
149 
150 inline
152 {
153  return boost::hash<OnixS::Eurex::MarketData::EOBI::OrderId>()(value);
154 }
155 
156 
157 }}}}
bool isOrderAffectsPriceLevel(const Order &order)
bool empty() const
Indicates whether book has no bids & asks.
Definition: EobiBook.cpp:253
size_t getHash(const OnixS::Eurex::MarketData::EOBI::OrderId &value)
Definition: EobiBookImpl.h:151
void checkSanity(const OrderBook &book)
checks whether the given book is properly built
Definition: EobiBook.cpp:407
size_t depth() const
Returns the maximum book depth.
Definition: EobiBook.cpp:243
Definition: Defines.h:30
Decimal type for better precision.
Definition: Numeric.h:63
size_t hash_value(OrderBookInternal const &book)
const OrderId & getOrderId(const Order &order)
Int64 SecurityId
Alias for Security Id type.
Definition: Defines.h:51
static void removeOrder(const Order &order, PriceLevel &level)
static void addOrder(const Order &order, PriceLevel &level)
PriceLevelCollections::Array PriceLevels
Sequence of price levels.
Definition: EobiBook.h:129
const PriceLevels & asks() const
Returns a set of descending bid prices for the given security.
Definition: EobiBook.cpp:258
OnixS::HandlerCore::MarketData::FullOrderDepthBook< PriceLevel, Order, OrderId, Decimal, BaseFullOrderDepthBook > OrderDepthBook
Definition: EobiBookImpl.h:63
OnixS::HandlerCore::MarketData::DefaultBaseFullOrderDepthBook::BaseAskMap BaseAskMap
Definition: EobiBookImpl.h:58
OnixS::HandlerCore::MarketData::DefaultBaseFullOrderDepthBook::BaseBidMap BaseBidMap
Definition: EobiBookImpl.h:59
const PriceLevels & bids() const
Returns a set of ascending ask prices for the given security.
Definition: EobiBook.cpp:263
Encapsulates price level concept.
Definition: EobiBook.h:55
const Decimal & getPrice(const Order &order)