OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  7.4.2
API documentation
Trade.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 #include <OnixS/Eurex/MarketData/Compiler.h>
26 
27 namespace OnixS
28 {
29  namespace Eurex
30  {
31  namespace MarketData
32  {
33  /// Trade.
34  template< class TTradeEntry >
35  class Trade
36  {
37  public:
38  /// Initializes an instance.
39  Trade (SecurityId id, UInt32 sequenceNumber, const TTradeEntry& tradeEntry);
40 
41  /// Unique instrument ID as qualified by the
42  /// exchange per tag 22-SecurityIDSource (tag 48).
43  SecurityId securityId() const;
44 
45  /// Defines when the trade happens.
46  ///
47  /// Only present for TradeCondition=AW.
49  {
50  return tradeEntry_.trdType();
51  }
52 
53  /// Defines the trade condition.
55  {
56  return tradeEntry_.tradeCondition();
57  }
58 
59  /// Trade volume
60  bool volume (Decimal& value) const
61  {
62  return tradeEntry_.mdEntrySize (value);
63  }
64 
65  /// Trade price
66  bool price (Decimal& value) const
67  {
68  return tradeEntry_.mdEntryPx (value);
69  }
70 
71  /// Returns group entry (FIX fields) of underlying message.
72  /// Entry contains all the data related with given trade.
73  const TTradeEntry& underlyingEntry() const
74  {
75  return tradeEntry_;
76  }
77 
78  /// Sequence number of the last processed message
80  {
81  return sequenceNumber_;
82  }
83 
84  /// Underlying entry size
85  UInt32 size() const;
86 
87  /// Returns text presentation.
88  std::string toString() const;
89 
90  /// Appends text presentation.
91  virtual void toString (std::string&) const = 0;
92 
93  virtual ~Trade() { }
94 
95  protected:
98 
99  // Underlying trade entry.
100  const TTradeEntry& tradeEntry_;
101  };
102 
103  template< class TTradeEntry >
105  : securityId_ (securityId)
106  , sequenceNumber_ (sequenceNumber)
107  , tradeEntry_ (tradeEntry)
108  {
109  }
110 
111  template< class TTradeEntry >
113  {
114  return securityId_;
115  }
116 
117  template< class TTradeEntry >
119  {
120  Decimal size;
121  tradeEntry_.mdEntrySize (size);
122  return size;
123  }
124 
125  template< class TTradeEntry >
126  std::string Trade<TTradeEntry>::toString() const
127  {
128  std::string str;
129 
130  toString (str);
131 
132  return str;
133  }
134 
135  /// Snapshot trade
136  class ONIXS_EUREX_EMDI_API SnapshotTrade : public Trade<MDSnapshotEntry>
137  {
138  public:
139  /// Appends text presentation.
140  void toString (std::string&) const ONIXS_EUREX_EMDI_OVERRIDE;
141 
142  protected:
143  /// Initializes an instance.
145 
146  private:
147  /// Initializes instance as reference to the other one.
148  SnapshotTrade (const SnapshotTrade&);
149 
150  /// Reinitializes instance as reference of other one.
151  SnapshotTrade& operator = (const SnapshotTrade&);
152 
153  // Underlying implementation.
154  void* impl_;
155  };
156 
157  /// Incremental trade
158  class ONIXS_EUREX_EMDI_API IncrementalTrade : public Trade<MDIncrementalEntry>
159  {
160  public:
161  /// MDEntryID
162  UInt32 entryId() const;
163 
164  /// Appends text presentation.
165  void toString (std::string&) const ONIXS_EUREX_EMDI_OVERRIDE;
166 
167  protected:
168  /// Initializes an instance.
170 
171  private:
172  /// Initializes instance as reference to the other one.
174 
175  /// Reinitializes instance as reference of other one.
176  IncrementalTrade& operator = (const IncrementalTrade&);
177 
178  // Underlying implementation.
179  void* impl_;
180  };
181  }
182  }
183 }
Trade(SecurityId id, UInt32 sequenceNumber, const TTradeEntry &tradeEntry)
Initializes an instance.
Definition: Trade.h:104
const TTradeEntry & tradeEntry_
Definition: Trade.h:100
TrdType::Enum type() const
Definition: Trade.h:48
UInt32 size() const
Underlying entry size.
Definition: Trade.h:118
unsigned int UInt32
Definition: Numeric.h:41
Definition: Defines.h:30
Decimal type for better precision.
Definition: Numeric.h:63
UInt32 sequenceNumber() const
Sequence number of the last processed message.
Definition: Trade.h:79
std::string toString() const
Returns text presentation.
Definition: Trade.h:126
Int64 SecurityId
Alias for Security Id type.
Definition: Defines.h:51
bool price(Decimal &value) const
Trade price.
Definition: Trade.h:66
SecurityId securityId() const
Definition: Trade.h:112
TradeConditionSet condition() const
Defines the trade condition.
Definition: Trade.h:54
bool volume(Decimal &value) const
Trade volume.
Definition: Trade.h:60
Market data snapshot entry.
Definition: DepthSnapshot.h:51
const TTradeEntry & underlyingEntry() const
Definition: Trade.h:73