libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
messages.hpp
Go to the documentation of this file.
1 #ifndef ISIMUD_EXCHANGES_BATSBOE_US_v2_MESSAGES_HPP
2 #define ISIMUD_EXCHANGES_BATSBOE_US_v2_MESSAGES_HPP
3 
4 /******************************************************************************
5 ** Copyright © 2015 by J.M.McGuiness, isimud@hussar.me.uk
6 **
7 ** This library is free software; you can redistribute it and/or
8 ** modify it under the terms of the GNU Lesser General Public
9 ** License as published by the Free Software Foundation; either
10 ** version 2.1 of the License, or (at your option) any later version.
11 **
12 ** This library is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ** Lesser General Public License for more details.
16 **
17 ** You should have received a copy of the GNU Lesser General Public
18 ** License along with this library; if not, write to the Free Software
19 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 
22 #include "config.h"
23 #include "../types.hpp"
24 #include "../../common/messages.hpp"
25 
26 #include "core/max_min.hpp"
27 
28 #include <boost/mpl/max_element.hpp>
29 #include <boost/mpl/min_element.hpp>
30 #include <boost/mpl/vector.hpp>
31 #include <boost/variant/variant.hpp>
32 
33 #include <iostream>
34 
35 namespace isimud { namespace ISIMUD_VER_NAMESPACE { namespace exchanges { namespace BATSBOE { namespace US {
36 
37 /**
38  From <a href="http://cdn.cboe.com/resources/membership/Cboe_US_Equities_BOE_Specification.pdf">"Cboe US Equities Binary Order Entry Specification" Version 2.3.6 June 25, 2019</a>.
39 
40  \todo
41 */
42 namespace v2 {
43 
44 struct MsgTypes {
45 
46  static inline constexpr const exchanges::common::mic_codes::ISO_10383_MIC_Codes MIC_code=exchanges::common::mic_codes::ISO_10383_MIC_Codes::ISO_10383_UNITED_STATES_OF_AMERICA_BATS;
47 
48  struct ref_data {};
49 
50  using MsgTypes_t=common::MsgType_t;
51  using MsgType_t=US::MsgType;
52  using UserName_t=common::UserName_t;
53  using Password_t=common::Password_t;
54  using SecurityID_t=common::SecurityID_t;
55  using SeqNum_t=common::SeqNum_t;
56  using Price_t=common::Price_t;
57  using Quantity_t=common::Quantity_t;
58  using ClientOrderID_t=common::ClientOrderID_t;
59  using OrderType=common::OrdType;
60  using Side=common::Side;
61  using TIF=common::TIF;
62  using OrderRejectReason=common::OrderRejectReason;
63  using LoginResponseStatus=common::LoginResponseStatus;
64  using logon_args_t=common::logon_args_t;
65 
68  using LogoutRequest=common::LogoutRequest;
69  using ClientHeartbeat=common::ClientHeartbeat;
71  using Logout=common::Logout;
72  using ServerHeartbeat=common::ServerHeartbeat;
73  using ReplayComplete=common::ReplayComplete;
74  using NewOrder_t=common::NewOrder;
75  using CancelOrder=common::CancelOrder;
76  using ModifyOrder=common::ModifyOrder;
77  using OrderAcknowledgement=common::OrderAcknowledgement;
78  using OrderRejected=common::OrderRejected;
79  using OrderModified=common::OrderModified;
80  using OrderRestated=common::OrderRestated;
81  using UserModifyRejected=common::UserModifyRejected;
82  using OrderCancelled=common::OrderCancelled;
83  using CancelRejected=common::CancelRejected;
84  using OrderExecution=common::OrderExecution;
85  using TradeCancelOrCorrect=common::TradeCancelOrCorrect;
86 
87  using ExecutionReport=OrderExecution;
88  using Heartbeat=ClientHeartbeat;
89  using OrderCancelRequest=CancelOrder;
90  using OrderCancelReject=CancelRejected;
91  using OrderCancelReplaceRequest=ModifyOrder;
92 
93  static inline constexpr MsgTypes_t MatchAll=static_cast<MsgTypes_t>(MsgType_t::MatchAll); ///< For the meta-state machine to allow a catch-all rule to reject anything unhandled.
94  static inline constexpr MsgTypes_t Exit=static_cast<MsgTypes_t>(MsgType_t::Exit); ///< For the meta-state machine: the exit state to exit the msm.
95 
100  NewOrder_t,
101  CancelOrder,
103  >;
104 
106  LogonReply,
107  Logout,
119  >;
120 
121  enum : std::size_t {
123  boost::mpl::deref<
124  boost::mpl::min_element<
125  boost::mpl::transform_view<client_to_exchange_messages_t, boost::mpl::sizeof_<boost::mpl::_1> >
126  >::type::base
127  >::type
128  ),
130  boost::mpl::deref<
131  boost::mpl::max_element<
132  boost::mpl::transform_view<client_to_exchange_messages_t, boost::mpl::sizeof_<boost::mpl::_1> >
133  >::type::base
134  >::type
135  ),
137  boost::mpl::deref<
138  boost::mpl::min_element<
139  boost::mpl::transform_view<exchange_to_client_messages_t, boost::mpl::sizeof_<boost::mpl::_1> >
140  >::type::base
141  >::type
142  ),
144  boost::mpl::deref<
145  boost::mpl::max_element<
146  boost::mpl::transform_view<exchange_to_client_messages_t, boost::mpl::sizeof_<boost::mpl::_1> >
147  >::type::base
148  >::type
149  ),
150  min_msg_size=libjmmcg::min<std::size_t, min_size_client_to_exchange_msg, min_size_exchange_to_client_msg>::value,
151  max_msg_size=libjmmcg::max<std::size_t, max_size_client_to_exchange_msg, max_size_exchange_to_client_msg>::value,
152  header_t_size=sizeof(typename LogonRequest::Header_t)
153  };
154  BOOST_MPL_ASSERT_RELATION(max_msg_size, >=, header_t_size);
155 
156  using msg_buffer_t=std::array<std::uint8_t, max_msg_size>;
159 
161 
162  static std::ostream &to_stream(std::ostream &) noexcept(false);
163 };
164 
165 /**
166  \test BATSBOE US v2 size tests.
167 */
168 namespace tests {
169 
170 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogoutRequest), <=, MsgTypes::max_size_client_to_exchange_msg);
171 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogoutRequest), <=, MsgTypes::max_size_exchange_to_client_msg);
172 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogoutRequest), <=, MsgTypes::max_msg_size);
173 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogonRequest), ==, 261);
174 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogoutRequest), ==, 10);
175 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::ClientHeartbeat), ==, 10);
176 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogonReply), ==, 11);
177 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::Logout), ==, 76);
178 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::ServerHeartbeat), ==, 10);
179 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::ReplayComplete), ==, 10);
180 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::NewOrder_t), ==, 157);
181 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::CancelOrder), ==, 36);
182 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::ModifyOrder), ==, 73);
183 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderAcknowledgement), ==, 245);
184 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderRejected), ==, 213);
185 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderModified), ==, 205);
186 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderRestated), ==, 216);
187 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::UserModifyRejected), ==, 108);
188 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderCancelled), ==, 191);
189 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::CancelRejected), ==, 100);
190 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderExecution), ==, 215);
191 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::TradeCancelOrCorrect), ==, 170);
192 
193 }
194 
195 } } } } } }
196 
197 #include "messages_impl.hpp"
198 
199 #endif