OnixS C++ Eurex T7 Market and Reference Data (EMDI, MDI, RDI, EOBI) Handlers 18.2.0
API documentation
Loading...
Searching...
No Matches
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
23
24#include <vector>
25
26namespace OnixS
27{
28 namespace Eurex
29 {
30 namespace MarketData
31 {
33 struct ONIXS_EUREX_EMDI_API PriceLevel
34 {
35 public:
38
41
43 Decimal price() const;
44
46 void price (Decimal value);
47
49 Quantity quantity() const;
50
52 void quantity (Quantity value);
53
56
58 void numberOfOrders (Quantity value);
59
61 std::string toString() const;
62
64 void toString (std::string&) const;
65
66 protected:
68
71 };
72
74 bool operator ==(const PriceLevel& l, const PriceLevel& r);
75
77 std::ostream& operator<< (std::ostream& s, const PriceLevel& lvl);
78
79
81 {
82 return price_;
83 }
84
85 inline void PriceLevel::price (Decimal value)
86 {
87 price_ = value;
88 }
89
91 {
92 return qty_;
93 }
94
95 inline void PriceLevel::quantity (Quantity value)
96 {
97 qty_ = value;
98 }
99
101 {
102 return ordersQty_;
103 }
104
106 {
107 ordersQty_ = value;
108 }
109
110 inline std::string PriceLevel::toString() const
111 {
112 std::string str;
113
114 toString (str);
115
116 return str;
117 }
118
119 bool isValid (const PriceLevel& level);
120
122 struct ONIXS_EUREX_EMDI_API PriceLevelCollections
123 {
125 typedef std::vector<PriceLevel> Array;
126
128 typedef Array::iterator ArrayEntry;
129
131 typedef Array::const_iterator ArrayConstEntry;
132 };
133
136
139
142
148 class ONIXS_EUREX_EMDI_API OrderBook
149 {
150 public:
152
154 virtual ~OrderBook();
155
158 SecurityId securityId() const;
159
161 virtual UInt32 lastMsgSeqNumProcessed() const = 0;
162
164 size_t depth() const;
165
167 bool empty() const;
168
170 virtual const PriceLevels& asks() const = 0;
171
173 virtual const PriceLevels& bids() const = 0;
174
176 virtual bool bestAsk (Decimal& price, Quantity& quantity) const = 0;
177
179 virtual bool bestBid (Decimal& price, Quantity& quantity) const = 0;
180
182 virtual UInt64 mdEntryTime () const = 0;
183
185 std::string toString() const;
186
188 void toString (std::string&) const;
189
191 std::string toShortString() const;
192
194 void toShortString (std::string&) const;
195
197 std::string toFormattedString() const;
198
200 void toFormattedString (std::string&) const;
201
204
207 void* operator new (size_t bookSize);
208
211 void operator delete (void* book);
212
213 protected:
214 // Security id.
216
217 // Depth (max num. of price levels) of book.
218 size_t depth_;
219
220 // Base initialization.
221 OrderBook (SecurityId securityId, size_t bookDepth);
222
223 private:
224 // No public copies are allowed.
225 // Snapshot creation is exposed instead.
226
227 OrderBook (const OrderBook& book);
228 OrderBook& operator= (const OrderBook& book);
229 };
230
232 void checkSanity (const OrderBook& book);
233
235 {
236 return securityId_;
237 }
238
239 inline size_t OrderBook::depth() const
240 {
241 return depth_;
242 }
243
244 inline bool OrderBook::empty() const
245 {
246 return bids().empty() && asks().empty();
247 }
248
249 inline std::string OrderBook::toString() const
250 {
251 std::string str;
252
253 toString (str);
254
255 return str;
256 }
257
258 inline std::string OrderBook::toShortString() const
259 {
260 std::string str;
261
262 toShortString (str);
263
264 return str;
265 }
266
267 inline std::string OrderBook::toFormattedString() const
268 {
269 std::string str;
270
271 toFormattedString (str);
272
273 return str;
274 }
275 }
276 }
277}
Decimal type for better precision.
Definition Numeric.h:66
virtual bool bestAsk(Decimal &price, Quantity &quantity) const =0
Returns best implied ask.
std::string toString() const
String presentation of the book.
Definition OrderBook.h:249
virtual ~OrderBook()
Destruction interface.
OrderBook * snapshot() const
Creates immutable snapshot of the book.
std::string toFormattedString() const
Returns formatted presentation of the book.
Definition OrderBook.h:267
virtual UInt32 lastMsgSeqNumProcessed() const =0
Sequence number of the last processed message.
bool empty() const
Indicates whether book has no bids & asks.
Definition OrderBook.h:244
size_t depth() const
Returns the maximum book depth.
Definition OrderBook.h:239
void toFormattedString(std::string &) const
Appends Formatted presentation of the book.
void toString(std::string &) const
String presentation of the book.
virtual const PriceLevels & asks() const =0
Returns a set of descending bid prices for the given security.
virtual bool bestBid(Decimal &price, Quantity &quantity) const =0
Returns best implied bid.
void toShortString(std::string &) const
Appends brief book info to the string.
std::string toShortString() const
Returns brief book info.
Definition OrderBook.h:258
OrderBook(SecurityId securityId, size_t bookDepth)
virtual const PriceLevels & bids() const =0
Returns a set of ascending ask prices for the given security.
virtual UInt64 mdEntryTime() const =0
For bids and offers the official time of book entry, for trades official time of execution (all in na...
UInt64 Quantity
Alias for Quantity type.
Definition Defines.h:54
PriceLevelCollections::Array PriceLevels
Sequence of price levels.
Definition OrderBook.h:135
std::ostream & operator<<(std::ostream &os, const Message &message)
unsigned int UInt32
Definition Numeric.h:41
bool operator==(const FieldValueRef &ref, const std::string &str)
bool isValid(const PriceLevel &level)
Int64 SecurityId
Alias for Security Id type.
Definition Defines.h:51
PriceLevelCollections::ArrayEntry PriceLevelsEntry
Iterator to access price levels with write permissions.
Definition OrderBook.h:138
PriceLevelCollections::ArrayConstEntry PriceLevelsConstEntry
Iterator over read-only collection of price levels.
Definition OrderBook.h:141
void checkSanity(const OrderBook &book)
checks whether the given book is properly built
Miscellaneous traits for PriceLevel class.
Definition OrderBook.h:123
Array::iterator ArrayEntry
Mutable entry iterator.
Definition OrderBook.h:128
std::vector< PriceLevel > Array
Sequential collection of price levels.
Definition OrderBook.h:125
Array::const_iterator ArrayConstEntry
Iterator for read-only access.
Definition OrderBook.h:131
Encapsulates price level concept.
Definition OrderBook.h:34
std::string toString() const
Returns string representation of the instance.
Definition OrderBook.h:110
PriceLevel(Decimal price, Quantity quantity, Quantity numberOfOrders)
Initializes the instances according to specified attributes.
PriceLevel()
Default initialization.
Decimal price() const
Price value.
Definition OrderBook.h:80
Quantity numberOfOrders() const
Total number of orders of given price.
Definition OrderBook.h:100
Quantity quantity() const
Quantify for the given price.
Definition OrderBook.h:90
void toString(std::string &) const
Appends representation of the instance to the string.