OnixS BME SENAF Handler C++ library  2.2.1
API documentation
OrderBook.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
5  * copyright law and international copyright treaties.
6  *
7  * Access to and use of the software is governed by the terms of the applicable
8  * ONIXS Software Services Agreement (the Agreement) and Customer end user
9  * license agreements granting a non-assignable, non-transferable and
10  * non-exclusive license to use the software for it's own data processing
11  * purposes under the terms defined in the Agreement.
12  *
13  * Except as otherwise granted within the terms of the Agreement, copying or
14  * reproduction of any part of this source code or associated reference material
15  * to any other location for further reproduction or redistribution, and any
16  * amendments to this copyright notice, are expressly prohibited.
17  *
18  * Any reproduction or redistribution for sale or hiring of the Software not in
19  * accordance with the terms of the Agreement is a violation of copyright law.
20  */
21 
22 #pragma once
23 
25 #include <OnixS/Senaf/MarketData/Export.h>
27 
28 namespace OnixS { namespace Senaf { namespace MarketData {
29 
30 typedef unsigned int MarketId;
31 
32 /// forward declarations
33 class OrderBookImpl;
34 class OrderBookProcessor;
35 
36 /// \brief Defines data for single price level of order book.
37 struct ONIXS_BME_SENAF_EXPORT PriceLevel
38 {
39  /// Raw exchange price (fixed point).
41 
42  /// Raw exchange yield (fixed point).
44 
45  /// Total order quantity at price.
46  int quantity;
47 
48  /// Positions count at price.
50 
51  /// Constructor.
52  explicit PriceLevel(
53  const Rational& inPrice = Rational(),
54  const Rational& inYield = Rational(),
55  int inQuantity = 0,
56  short inPositionCount = 0
57  )
58  : price(inPrice)
59  , yield(inYield)
60  , quantity(inQuantity)
61  , positionCount(inPositionCount)
62  {
63  }
64 };
65 
67 
68 /// \brief Book instance composing price level book and full order depth book.
69 class ONIXS_BME_SENAF_EXPORT OrderBook
70 {
71  friend class OrderBookProcessor;
72 
73 public:
74  /// Unique identifier of a market.
75  MarketId marketId() const;
76 
77  /// Returns the maximum book depth.
78  std::size_t depth() const;
79 
80  /// Indicates whether book has no bids & asks.
81  bool empty() const;
82 
83  /// Gets bid side of the price level book.
84  const PriceLevelArray& bids() const;
85 
86  /// Gets offer side of the price level book.
87  const PriceLevelArray& asks() const;
88 
89  /// Returns brief book info.
90  std::string brief() const;
91 
92  /// Appends brief book info to the string.
93  void brief(std::string&) const;
94 
95  /// String presentation of the book.
96  std::string toString() const;
97 
98  /// String presentation of the book.
99  void toString(std::string&) const;
100 
101  /// Destructor
102  ~OrderBook();
103 
104 private:
105  OrderBook(OrderBookImpl*);
106 
107  // No implementation
108  OrderBook(const OrderBook&);
109  OrderBook& operator=(const OrderBook&);
110 
111  OrderBookImpl* impl_;
112 };
113 
114 inline std::string OrderBook::brief() const
115 {
116  std::string str;
117  brief(str);
118  return str;
119 }
120 
121 inline std::string OrderBook::toString() const
122 {
123  std::string str;
124  toString(str);
125  return str;
126 }
127 
128 }}} // namespace OnixS::Senaf::MarketData
std::string toString() const
String presentation of the book.
Definition: OrderBook.h:121
PriceLevel(const Rational &inPrice=Rational(), const Rational &inYield=Rational(), int inQuantity=0, short inPositionCount=0)
Constructor.
Definition: OrderBook.h:52
ArrayRef< const PriceLevel, std::size_t > PriceLevelArray
Definition: OrderBook.h:66
Book instance composing price level book and full order depth book.
Definition: OrderBook.h:69
unsigned int MarketId
Definition: OrderBook.h:30
Defines data for single price level of order book.
Definition: OrderBook.h:37
Rational number representation.
Definition: Rational.h:32
int quantity
Total order quantity at price.
Definition: OrderBook.h:46
Rational price
Raw exchange price (fixed point).
Definition: OrderBook.h:40
std::string brief() const
Returns brief book info.
Definition: OrderBook.h:114
Rational yield
Raw exchange yield (fixed point).
Definition: OrderBook.h:43
short positionCount
Positions count at price.
Definition: OrderBook.h:49