OnixS C++ CME MDP Premium Market Data Handler  5.8.9
API Documentation
ImpliedPriceLevel.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 
23 #include <string>
24 
25 #include <OnixS/CME/MDH/Decimal.h>
26 
28 
29 /// Encapsulates price level concept.
31 {
32 public:
33  /// Initializes undefined level.
35  : exist_(false)
36  , price_()
37  , qty_(0)
38  {
39  }
40 
41  /// Initializes as copy of other level.
43  : exist_(other.exist_)
44  , price_(other.price_)
45  , qty_(other.qty_)
46  {
47  }
48 
49  /// Initializes defined level
50  /// according to specified attributes.
51  ImpliedPriceLevel(const Decimal& price, Int32 qty)
52  : exist_(true)
53  , price_(price)
54  , qty_(qty)
55  {
56  }
57 
58  /// Cleans everything up.
60 
61  /// Identifies whether price level exist.
62  bool exist() const
63  {
64  return exist_;
65  }
66 
67  /// Updates existence status.
68  bool& exist()
69  {
70  return exist_;
71  }
72 
73  /// Price value.
74  ///
75  /// @note For CME Globex channels (market data groups)
76  /// value presents if price level exists. However, for
77  /// CME Partner Exchanges channels like BVMF price value
78  /// may be NULL in a valid (existent) price level.
79  ///
80  /// @see NullPRICE.
81  const Decimal& price() const
82  {
83  return price_;
84  }
85 
86  /// Price value.
88  {
89  return price_;
90  }
91 
92  /// Quantify for the given price.
93  Int32 quantity() const
94  {
95  return qty_;
96  }
97 
98  /// Quantify for the given price.
100  {
101  return qty_;
102  }
103 
104  // Re-initializes as copy of other instance.
106  {
107  price_ = other.price_;
108  qty_ = other.qty_;
109  exist_ = other.exist_;
110 
111  return *this;
112  }
113 
114 private:
115  // Indicates whether data is available.
116  bool exist_;
117 
118  // Price value for the level.
119  Decimal price_;
120 
121  // Quantity component.
122  Int32 qty_;
123 };
124 
125 /// Serializes price level attributes into a string.
127 void toStr(std::string&, const ImpliedPriceLevel&);
128 
129 /// Serializes price level attributes into a string.
130 inline std::string toStr(const ImpliedPriceLevel& priceLevel)
131 {
132  std::string str;
133 
134  toStr(str, priceLevel);
135 
136  return str;
137 }
138 
Decimal & price()
Price value.
ImpliedPriceLevel & operator=(const ImpliedPriceLevel &other)
Int32 quantity() const
Quantify for the given price.
Int32 Int32
int32.
Definition: Fields.h:60
bool & exist()
Updates existence status.
Int32 & quantity()
Quantify for the given price.
std::string toStr(const ImpliedPriceLevel &priceLevel)
Serializes price level attributes into a string.
#define ONIXS_CMEMDH_LTWT
Definition: Bootstrap.h:46
Encapsulates price level concept.
ImpliedPriceLevel(const ImpliedPriceLevel &other)
Initializes as copy of other level.
~ImpliedPriceLevel()
Cleans everything up.
const Decimal & price() const
Price value.
A real number with floating exponent.
Definition: Decimal.h:136
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:160
ImpliedPriceLevel()
Initializes undefined level.
bool exist() const
Identifies whether price level exist.
ImpliedPriceLevel(const Decimal &price, Int32 qty)
Initializes defined level according to specified attributes.
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68