libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
messages_impl.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2015 by J.M.McGuiness, isimud@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 namespace isimud { namespace ISIMUD_VER_NAMESPACE { namespace exchanges { namespace FIX {
20 
21 namespace common {
22 
23 template<> inline __stdcall
25 : Header_t() {
30  ++data;
32  const int i=convert(instID, data, this->data_.size()-(data-this->data_.begin()));
33  assert(i>0);
34  data+=i;
36  *data=static_cast<char>(oT);
37  ++data;
39  *data=static_cast<char>(t);
40  ++data;
42  const int j=convert(p, data, this->data_.size()-(data-this->data_.begin()));
43  assert(j>0);
44  data+=j;
46  const int k=convert(ordQty, data, this->data_.size()-(data-this->data_.begin()));
47  assert(k>0);
48  data+=k;
50  *data=static_cast<char>(s);
51  ++data;
54 // TODO msg.orderRejectCode();
56 }
57 
58 template<> inline __stdcall
60 : Header_t() {
65  ++data;
67  const int i=convert(instID, data, this->data_.size()-(data-this->data_.begin()));
68  assert(i>0);
69  data+=i;
71  *data=static_cast<char>(eT);
72  ++data;
74  const int j=convert(price, data, this->data_.size()-(data-this->data_.begin()));
75  assert(j>0);
76  data+=j;
78  const int k=convert(execdQty, data, this->data_.size()-(data-this->data_.begin()));
79  assert(k>0);
80  data+=k;
82  const int l=convert(leavesQty, data, this->data_.size()-(data-this->data_.begin()));
83  assert(l>0);
84  data+=l;
86  *data=static_cast<char>(s);
87  ++data;
90 // TODO msg.orderRejectCode();
92 }
93 
94 }
95 
96 namespace v5_0sp2 {
97 
98 template<class Msg>
99 inline constexpr bool
100 VersionSpecific::is_valid(Msg const &) noexcept(true) {
101  return true;
102 }
103 
104 template<class Msg>
105 inline bool
106 LogoutRequestSpecific::is_valid(Msg const &m) noexcept(true) {
107  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
108  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
109  // TODO
110  return has_MsgType;
111 }
112 
113 template<class Msg>
114 inline bool
115 HeartbeatSpecific::is_valid(Msg const &m) noexcept(true) {
116  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
117  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
118  return has_MsgType;
119 }
120 
121 template<class Msg>
122 inline bool
123 LogonSpecific::is_valid(Msg const &m) noexcept(true) {
124  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
125  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
126  const bool has_username=m.template search<common::FieldsFast::Username>();
127  const bool has_password=m.template search<common::FieldsFast::Password>();
128  return has_MsgType && has_username && has_password;
129 }
130 
131 template<class Msg>
132 inline bool
133 NewOrderSingleSpecific::is_valid(Msg const &m) noexcept(true) {
134  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
135  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
136  const bool has_ClOrdID=m.template search<common::FieldsFast::ClOrdID>();
137  const bool has_Side=m.template search<common::FieldsFast::Side>();
138  const bool has_TransactTime=m.template search<common::FieldsFast::TransactTime>();
139  const bool has_OrderQty=m.template search<common::FieldsFast::OrderQty>();
140  const bool has_OrdType=m.template search<common::FieldsFast::OrdType>();
141  const bool has_SecurityIDSource=m.template search<common::FieldsFast::SecurityIDSource>();
142  const bool is_ISIN=(has_SecurityIDSource && (m.template find<common::FieldsFast::SecurityIDSource>().first[0]==static_cast<std::underlying_type<common::SecurityIDSource>::type>(common::SecurityIDSource::ISIN)));
143  const bool has_ISIN=(is_ISIN && m.template search<common::FieldsFast::SecurityID>());
144  return has_MsgType && has_ClOrdID && has_Side && has_TransactTime && has_OrderQty && has_OrdType && has_ISIN;
145 }
146 
147 template<class Msg>
148 inline bool
149 OrderCancelRequestSpecific::is_valid(Msg const &m) noexcept(true) {
150  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
151  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
152  const bool has_ClOrdID=m.template search<common::FieldsFast::ClOrdID>();
153  const bool has_Symbol=m.template search<common::FieldsFast::Symbol>();
154  const bool has_Side=m.template search<common::FieldsFast::Side>();
155  const bool has_TransactTime=m.template search<common::FieldsFast::TransactTime>();
156  const bool has_OrderQty=m.template search<common::FieldsFast::OrderQty>();
157  return has_MsgType && has_ClOrdID && has_Symbol && has_Side && has_TransactTime && has_OrderQty;
158 }
159 
160 template<class Msg>
161 inline bool
162 OrderCancelReplaceSpecific::is_valid(Msg const &m) noexcept(true) {
163  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
164  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
165  const bool has_MsgSeqNum=m.template search<common::FieldsFast::MsgSeqNum>();
166  const bool has_SenderCompID=m.template search<common::FieldsFast::SenderCompID>();
167  const bool has_TargetCompID=m.template search<common::FieldsFast::TargetCompID>();
168  const bool has_SendingTime=m.template search<common::FieldsFast::SendingTime>();
169  const bool has_ClOrdID=m.template search<common::FieldsFast::ClOrdID>();
170  const bool has_Symbol=m.template search<common::FieldsFast::Symbol>();
171  const bool has_Side=m.template search<common::FieldsFast::Side>();
172  const bool has_TransactTime=m.template search<common::FieldsFast::TransactTime>();
173  const bool has_OrderQty=m.template search<common::FieldsFast::OrderQty>();
174  const bool has_OrdType=m.template search<common::FieldsFast::OrdType>();
175  return has_MsgType && has_MsgSeqNum && has_SenderCompID && has_TargetCompID && has_SendingTime && has_ClOrdID && has_Symbol && has_Side && has_TransactTime && has_OrderQty && has_OrdType;
176 }
177 
178 template<class Msg>
179 inline bool
180 ExecutionReportSpecific::is_valid(Msg const &m) noexcept(true) {
181  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
182  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
183  const bool has_MsgSeqNum=m.template search<common::FieldsFast::MsgSeqNum>();
184  // TODO verify that the required fields are present.
185  return has_MsgType && has_MsgSeqNum;
186 }
187 
188 template<class Msg>
189 inline bool
190 LogonReplySpecific::is_valid(Msg const &m) noexcept(true) {
191  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
192  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
193  // TODO verify that the required fields are present.
194  return has_MsgType;
195 }
196 
197 template<class Msg>
198 inline bool
199 LogoutSpecific::is_valid(Msg const &m) noexcept(true) {
200  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
201  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
202  // TODO verify that the required fields are present.
203  return has_MsgType;
204 }
205 
206 template<class Msg>
207 inline bool
208 CancelOrderSpecific::is_valid(Msg const &m) noexcept(true) {
209  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
210  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
211  // TODO verify that the required fields are present.
212  return has_MsgType;
213 }
214 
215 template<class Msg>
216 inline bool
217 BusinessMessageRejectSpecific::is_valid(Msg const &m) noexcept(true) {
218  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
219  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
220  const bool has_RefSeqNum=m.template search<common::FieldsFast::RefSeqNum>();
221  // TODO verify that the required fields are present.
222  return has_MsgType && has_RefSeqNum;
223 }
224 
225 template<class Msg>
226 inline bool
227 ModifyOrderSpecific::is_valid(Msg const &m) noexcept(true) {
228  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
229  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
230  // TODO verify that the required fields are present.
231  return has_MsgType;
232 }
233 
234 template<class Msg>
235 inline bool
236 TradeCaptureReportSpecific::is_valid(Msg const &m) noexcept(true) {
237  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
238  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
239  // TODO verify that the required fields are present.
240  return has_MsgType;
241 }
242 
243 template<class Msg>
244 inline bool
245 TradeCaptureReportRequestSpecific::is_valid(Msg const &m) noexcept(true) {
246  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
247  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
248  // TODO verify that the required fields are present.
249  return has_MsgType;
250 }
251 
252 template<class Msg>
253 inline bool
254 OrderAcknowledgementSpecific::is_valid(Msg const &m) noexcept(true) {
255  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
256  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
257  // TODO verify that the required fields are present.
258  return has_MsgType;
259 }
260 
261 template<class Msg>
262 inline bool
263 OrderRejectedSpecific::is_valid(Msg const &m) noexcept(true) {
264  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
265  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
266  return has_MsgType;
267 }
268 
269 template<class Msg>
270 inline bool
271 OrderModifiedSpecific::is_valid(Msg const &m) noexcept(true) {
272  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
273  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
274  // TODO verify that the required fields are present.
275  return has_MsgType;
276 }
277 
278 template<class Msg>
279 inline bool
280 OrderRestatedSpecific::is_valid(Msg const &m) noexcept(true) {
281  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
282  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
283  // TODO verify that the required fields are present.
284  return has_MsgType;
285 }
286 
287 template<class Msg>
288 inline bool
289 UserModifyRejectedSpecific::is_valid(Msg const &m) noexcept(true) {
290  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
291  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
292  // TODO verify that the required fields are present.
293  return has_MsgType;
294 }
295 
296 template<class Msg>
297 inline bool
298 OrderCancelledSpecific::is_valid(Msg const &m) noexcept(true) {
299  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
300  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
301  // TODO verify that the required fields are present.
302  return has_MsgType;
303 }
304 
305 template<class Msg>
306 inline bool
307 CancelRejectedSpecific::is_valid(Msg const &m) noexcept(true) {
308  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
309  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
310  const bool has_MsgSeqNum=m.template search<common::FieldsFast::MsgSeqNum>();
311  const bool has_ClOrdID=m.template search<common::FieldsFast::ClOrdID>();
312  // TODO verify that the required fields are present.
313  return has_MsgType && has_MsgSeqNum && has_ClOrdID;
314 }
315 
316 template<class Msg>
317 inline bool
318 OrderExecutionSpecific::is_valid(Msg const &m) noexcept(true) {
319  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
320  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
321  // TODO verify that the required fields are present.
322  return has_MsgType;
323 }
324 
325 template<class Msg>
326 inline bool
327 TradeCaptureReportAckSpecific::is_valid(Msg const &m) noexcept(true) {
328  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
329  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
330  // TODO verify that the required fields are present.
331  return has_MsgType;
332 }
333 
334 template<class Msg>
335 inline bool
336 TradeCaptureReportRequestAckSpecific::is_valid(Msg const &m) noexcept(true) {
337  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
338  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
339  // TODO verify that the required fields are present.
340  return has_MsgType;
341 }
342 
343 template<class Msg>
344 inline bool
345 RejectSpecific::is_valid(Msg const &m) noexcept(true) {
346  auto const &msg_type=m.template find<common::FieldsFast::MsgType>();
347  const bool has_MsgType=std::equal(msg_type.first, msg_type.second, Msg::msg_version_t::msg_type::value);
348  // TODO verify that the required fields are present.
349  return has_MsgType;
350 }
351 
352 }
353 
354 } } } }