OnixS BME SENAF Handler C++ library  2.0.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 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 
22 #include <OnixS/Senaf/MarketData/Export.h>
25 
26 namespace OnixS { namespace Senaf { namespace MarketData {
27 
28 typedef unsigned int MarketId;
29 
30 /// forward declarations
31 class OrderBookImpl;
32 class OrderBookProcessor;
33 
34 /// \brief Defines data for single price level of order book.
35 struct ONIXS_BME_SENAF_EXPORT PriceLevel
36 {
37  /// Raw exchange price (fixed point).
39 
40  /// Raw exchange yield (fixed point).
42 
43  /// Total order quantity at price.
44  int quantity;
45 
46  /// Positions count at price.
48 
49  /// Constructor.
50  explicit PriceLevel(
51  const Rational& inPrice = Rational()
52  , const Rational& inYield = Rational()
53  , int inQuantity = 0
54  , short inPositionCount = 0
55  )
56  : price(inPrice)
57  , yield(inYield)
58  , quantity(inQuantity)
59  , positionCount(inPositionCount)
60  {
61  }
62 };
63 
65 
66 /// \brief Book instance composing price level book and full order depth book.
67 class ONIXS_BME_SENAF_EXPORT OrderBook
68 {
69 friend class OrderBookProcessor;
70 public:
71  /// Unique identifier of a market.
72  MarketId marketId() const;
73 
74  /// Returns the maximum book depth.
75  std::size_t depth() const;
76 
77  /// Indicates whether book has no bids & asks.
78  bool empty() const;
79 
80  /// Gets bid side of the price level book.
81  const PriceLevelArray& bids() const;
82 
83  /// Gets offer side of the price level book.
84  const PriceLevelArray& asks() const;
85 
86  /// Returns brief book info.
87  std::string brief() const;
88 
89  /// Appends brief book info to the string.
90  void brief(std::string&) const;
91 
92  /// String presentation of the book.
93  std::string toString() const;
94 
95  /// String presentation of the book.
96  void toString(std::string&) const;
97 
98  /// Destructor
99  ~OrderBook();
100 
101 private:
102  OrderBook(OrderBookImpl*);
103 
104  // No implementation
105  OrderBook(const OrderBook&);
106  OrderBook& operator=(const OrderBook&);
107 
108  OrderBookImpl* impl_;
109 };
110 
111 inline std::string OrderBook::brief() const
112 {
113  std::string str;
114  brief(str);
115  return str;
116 }
117 
118 inline std::string OrderBook::toString() const
119 {
120  std::string str;
121  toString(str);
122  return str;
123 }
124 
125 }}}
std::string toString() const
String presentation of the book.
Definition: OrderBook.h:118
PriceLevel(const Rational &inPrice=Rational(), const Rational &inYield=Rational(), int inQuantity=0, short inPositionCount=0)
Constructor.
Definition: OrderBook.h:50
ArrayRef< const PriceLevel, std::size_t > PriceLevelArray
Definition: OrderBook.h:64
Book instance composing price level book and full order depth book.
Definition: OrderBook.h:67
unsigned int MarketId
Definition: OrderBook.h:28
Defines data for single price level of order book.
Definition: OrderBook.h:35
Rational number representation.
Definition: Rational.h:30
int quantity
Total order quantity at price.
Definition: OrderBook.h:44
Rational price
Raw exchange price (fixed point).
Definition: OrderBook.h:38
std::string brief() const
Returns brief book info.
Definition: OrderBook.h:111
Rational yield
Raw exchange yield (fixed point).
Definition: OrderBook.h:41
short positionCount
Positions count at price.
Definition: OrderBook.h:47