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