OnixS C++ eSpeed ITCH Market Data Handler 1.7.3
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
22#include <vector>
23
28
29
31
32struct Order;
33
34struct ONIXS_ESPEED_ITCH_API OrderInfo
35{
37 OrderInfo (OrderId orderId, Quantity quantity);
38
41};
42
43typedef std::vector<OrderInfo> OrderInfos;
44
46struct ONIXS_ESPEED_ITCH_API PriceLevel
47{
49 explicit
52
54
55#if defined(ONIXS_ESPEED_ITCH_COMPILER_CXX_RVALUE_REFERENCES) && ONIXS_ESPEED_ITCH_COMPILER_CXX_RVALUE_REFERENCES
56
59
61 operator=(PriceLevel&& other)
63
64#endif
65
67
69 operator=(const PriceLevel& other);
70
72 const Price8& price() const;
73
76
79
81 const OrderInfos& orders() const;
82
85
87 std::string toString() const;
88
90 void toString (std::string&) const;
91
92 private:
94 void price (const Price8& value);
95
97 void quantity (Quantity value);
98
100 void addOrderId (OrderId id, Quantity quantity);
101
103 void removeOrderId (OrderId id);
104
105 private:
106 Price8 price_;
107 Quantity qty_;
108 OrderInfos orders_;
109
110 friend struct Order;
111};
112
113const Price8& getPrice (const PriceLevel& level);
114
116
117ONIXS_ESPEED_ITCH_API
118std::ostream& operator << (std::ostream& stream, const PriceLevel& value);
119
121struct ONIXS_ESPEED_ITCH_API PriceLevelCollections
122{
124 typedef std::vector<PriceLevel> Array;
125
127 typedef Array::iterator ArrayEntry;
128
130 typedef Array::const_iterator ArrayConstEntry;
131};
132
135
138
141
142class ONIXS_ESPEED_ITCH_API OrderBook
143{
144 public:
147
149 virtual ~OrderBook();
150
153
155 bool empty() const;
156
158 const PriceLevels& asks() const;
159
161 const PriceLevels& bids() const;
162
164 size_t depth() const;
165
167 std::string toString() const;
168
170 void toString (std::string&) const;
171
173 std::string toShortString() const;
174
176 void toShortString (std::string&) const;
177
179 std::string toFormattedString() const;
180
182 void toFormattedString (std::string&) const;
183
184 bool bestAsk (Price8& price, Quantity& quantity) const;
185
186 bool bestBid (Price8& price, Quantity& quantity) const;
187
189 void setUserPointer (void* pointer);
190
192 void* getUserPointer() const;
193
194 private:
195 virtual const PriceLevels& doAsks() const = 0;
196 virtual const PriceLevels& doBids() const = 0;
197 virtual OrderBookId doOrderBookId() const = 0;
198 virtual size_t doDepth() const = 0;
199 virtual bool doBestAsk (Price8& price, Quantity& quantity) const = 0;
200 virtual bool doBestBid (Price8& price, Quantity& quantity) const = 0;
201
202 private:
203 void* userPointer_;
204};
205
206
207ONIXS_ESPEED_ITCH_API
208std::ostream& operator << (std::ostream& stream, const OrderBook& book);
209
211void checkSanity (const OrderBook& book);
212
#define ONIXS_ESPEED_ITCH_NAMESPACE_BEGIN
Definition Bootstrap.h:27
#define ONIXS_ESPEED_ITCH_NAMESPACE_END
Definition Bootstrap.h:31
#define ONIXS_ESPEED_ITCH_NOTHROW
Definition Compiler.h:27
Int64 Price8
Alias for Price type (8 bytes).
Definition Defines.h:52
UInt64 OrderId
Alias for OrderId type.
Definition Defines.h:40
UInt32 OrderBookId
Alias for Security Id type.
Definition Defines.h:43
UInt32 Quantity
Alias for Quantity type.
Definition Defines.h:46
PriceLevelCollections::Array PriceLevels
Sequence of price levels.
Definition OrderBook.h:134
std::vector< OrderInfo > OrderInfos
Definition OrderBook.h:43
PriceLevelCollections::ArrayEntry PriceLevelsEntry
Iterator to access price levels with write permissions.
Definition OrderBook.h:137
bool isValid(const PriceLevel &level) ONIXS_ESPEED_ITCH_NOTHROW
PriceLevelCollections::ArrayConstEntry PriceLevelsConstEntry
Iterator over read-only collection of price levels.
Definition OrderBook.h:140
void checkSanity(const OrderBook &book)
checks whether the given book is properly built
ONIXS_ESPEED_ITCH_API std::ostream & operator<<(std::ostream &stream, const PriceLevel &value)
const Price8 & getPrice(const PriceLevel &level)
bool bestAsk(Price8 &price, Quantity &quantity) const
std::string toString() const
String presentation of the book.
void setUserPointer(void *pointer)
sets user data pointer
virtual ~OrderBook()
Destruction interface.
std::string toFormattedString() const
Returns formatted presentation of the book.
const PriceLevels & bids() const
Returns a set of ascending ask prices for the given security.
OrderBookId orderBookId() const
Unique instrument Id as qualified.
bool empty() const
Indicates whether book has no bids & asks.
size_t depth() const
Returns the maximum book depth.
void toFormattedString(std::string &) const
Appends Formatted presentation of the book.
const PriceLevels & asks() const
Returns a set of descending bid prices for the given security.
void toString(std::string &) const
String presentation of the book.
OrderBook()
Base initialization.
void toShortString(std::string &) const
Appends brief book info to the string.
bool bestBid(Price8 &price, Quantity &quantity) const
std::string toShortString() const
Returns brief book info.
void * getUserPointer() const
returns kept user data pointer
OrderId orderId_
Definition OrderBook.h:39
OrderInfo(OrderId orderId, Quantity quantity)
Quantity quantity_
Definition OrderBook.h:40
Miscellaneous traits for PriceLevel class.
Definition OrderBook.h:122
Array::iterator ArrayEntry
Mutable entry iterator.
Definition OrderBook.h:127
std::vector< PriceLevel > Array
Sequential collection of price levels.
Definition OrderBook.h:124
Array::const_iterator ArrayConstEntry
Iterator for read-only access.
Definition OrderBook.h:130
Encapsulates price level concept.
Definition OrderBook.h:47
PriceLevel & operator=(const PriceLevel &other)
std::string toString() const
Returns string representation of the instance.
PriceLevel(const Price8 &price, Quantity quantity=0, Quantity numberOfOrders=0, const OrderInfos &orders=OrderInfos())
Initializes the instances according to specified attributes.
const OrderInfos & orders() const
orders ids for a given level
const Price8 & price() const
Price value.
void swap(PriceLevel &) ONIXS_ESPEED_ITCH_NOTHROW
swap values
Quantity numberOfOrders() const
Total number of orders of given price.
Quantity quantity() const
Quantify for the given price.
friend struct Order
Definition OrderBook.h:110
void toString(std::string &) const
Appends representation of the instance to the string.
PriceLevel(const PriceLevel &)