OnixS C++ CME MDP Premium Market Data Handler 5.11.1
Users' manual and API documentation
Loading...
Searching...
No Matches
ConsolidatedPriceLevel.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
25
27
33{
34public:
36 constexpr ConsolidatedPriceLevel() noexcept = default;
37
41 : direct_(&direct)
42 , implied_(&null_)
43 {
44 }
45
49 : direct_(&null_)
50 , implied_(&implied)
51 {
52 }
53
58 : direct_(&direct)
59 , implied_(&implied)
60 {
61 }
62
65 constexpr ConsolidatedPriceLevel(const ConsolidatedPriceLevel& other) noexcept = default;
66
69 constexpr ConsolidatedPriceLevel(ConsolidatedPriceLevel&& other) noexcept = default;
70
73
77 constexpr bool exist() const noexcept
78 {
79 return (direct_->exist() || implied_->exist());
80 }
81
88 constexpr const Messaging::Decimal& price() const noexcept
89 {
90 return (direct_->exist() ? direct_->price() : implied_->price());
91 }
92
99 constexpr MbpBookQuantity quantity() const noexcept
100 {
101 return (direct_->quantity() + implied_->quantity());
102 }
103
109 constexpr const DirectPriceLevel& direct() const noexcept
110 {
111 return *direct_;
112 }
113
116 void consolidate(const DirectPriceLevel& direct) noexcept
117 {
118 direct_ = &direct;
119 }
120
126 constexpr const ImpliedPriceLevel& implied() const noexcept
127 {
128 return *implied_;
129 }
130
134 {
135 implied_ = &implied;
136 }
137
141 constexpr operator ImpliedPriceLevel() const noexcept
142 {
143 return direct_->exist() ? ImpliedPriceLevel(direct_->price(), quantity()) : *implied_;
144 }
145
149 ConsolidatedPriceLevel& operator=(const ConsolidatedPriceLevel& other) noexcept = default;
150
155
156private:
157 // Direct price level component.
158 const DirectPriceLevel* direct_{&null_};
159
160 // Implied price level component.
161 const ImpliedPriceLevel* implied_{&null_};
162
163 // Used to make all references valid.
164 ONIXS_CMEMDH_LTWT_EXPORTED static constexpr DirectPriceLevel null_{};
165};
166
171void toStr(std::string& str, const ConsolidatedPriceLevel& priceLevel);
172
176inline ONIXS_CMEMDH_NODISCARD std::string toStr(const ConsolidatedPriceLevel& priceLevel)
177{
178 std::string str;
179
180 toStr(str, priceLevel);
181
182 return str;
183}
184
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:69
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:61
#define ONIXS_CMEMDH_LTWT_EXPORTED
Definition Bootstrap.h:62
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:73
#define ONIXS_CMEMDH_EXPORTED
Definition Compiler.h:163
#define ONIXS_CMEMDH_NODISCARD
Definition Compiler.h:165
Represents one consolidated book price level.
void consolidate(const ImpliedPriceLevel &implied) noexcept
Replaces the implied component price level reference.
constexpr ConsolidatedPriceLevel(const ConsolidatedPriceLevel &other) noexcept=default
Constructs a price level as a copy of another instance.
constexpr ConsolidatedPriceLevel(const DirectPriceLevel &direct, const ImpliedPriceLevel &implied) noexcept
Constructs a price level from direct and implied book data.
constexpr bool exist() const noexcept
Checks whether direct or implied data exists at this level.
ConsolidatedPriceLevel & operator=(const ConsolidatedPriceLevel &other) noexcept=default
Replaces this price level with a copy of another instance.
ConsolidatedPriceLevel & operator=(ConsolidatedPriceLevel &&other) noexcept=default
Replaces this price level by moving another instance.
constexpr ConsolidatedPriceLevel() noexcept=default
Constructs a price level with no consolidated data.
constexpr ConsolidatedPriceLevel(ConsolidatedPriceLevel &&other) noexcept=default
Constructs a price level by moving another instance.
constexpr MbpBookQuantity quantity() const noexcept
Gets the consolidated aggregate quantity.
constexpr const ImpliedPriceLevel & implied() const noexcept
Gets the implied component price level.
constexpr const DirectPriceLevel & direct() const noexcept
Gets the direct component price level.
void consolidate(const DirectPriceLevel &direct) noexcept
Replaces the direct component price level reference.
constexpr ConsolidatedPriceLevel(const ImpliedPriceLevel &implied) noexcept
Constructs a price level from implied book data only.
~ConsolidatedPriceLevel()=default
Destroys the price level.
constexpr const Messaging::Decimal & price() const noexcept
Gets the consolidated price.
Represents one direct book price level.
Represents one implied book price level.
constexpr bool exist() const noexcept
Checks whether the price level is present in the book.
FloatingPointDecimal< DecimalMantissa, DecimalExponent > Decimal
Universal decimal type.
Messaging::Int64 MbpBookQuantity
Represents an aggregate quantity at a market-by-price level.
void toStr(std::string &str, BookState::Enum bookState)
Appends a string representation of a book state.