1 #ifndef libjmmcg_isimud_exchanges_BATSBOE_US_v1_messages_hpp
2 #define libjmmcg_isimud_exchanges_BATSBOE_US_v1_messages_hpp
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #include "config.h"
25 #include "../types.hpp"
26 #include "../../common/messages.hpp"
27
28 #include "core/max_min.hpp"
29
30 #include <boost/mpl/max_element.hpp>
31 #include <boost/mpl/min_element.hpp>
32 #include <boost/mpl/vector.hpp>
33 #include <boost/variant/variant.hpp>
34
35 #include <iostream>
36
37 namespace isimud { namespace exchanges { namespace BATSBOE { namespace US {
38
39
40
41
42
43
44 namespace v1 {
45
46 struct MsgTypes {
47
48 static inline constexpr const isimud::exchanges::common::mic_codes::ISO_10383_MIC_Codes MIC_code=isimud::exchanges::common::mic_codes::ISO_10383_MIC_Codes::ISO_10383_UNITED_STATES_OF_AMERICA_BATS;
49
50 struct ref_data {};
51 using ref_data_t=ref_data const &;
52
53 using MsgTypes_t=common::MsgType_t;
54 using MsgType_t=common::MsgType;
55 using UserName_t=common::UserName_t;
56 using Password_t=common::Password_t;
57 using SecurityID_t=common::SecurityID_t;
58 using Price_t=common::Price_t;
59 using ClientOrderID_t=common::ClientOrderID_t;
60 using OrderType=common::OrdType;
61 using Side=common::Side;
62 using OrderRejectReason=common::OrderRejectReason;
63 using LoginResponseStatus=common::LoginResponseStatus;
64 using logon_args_t=common::logon_args_t;
65
66 using LogonRequest=common::LogonRequest<MsgType, MsgType::LogonRequest>;
67 using Header_t=LogonRequest::Header_t;
68 using LogoutRequest=common::LogoutRequest;
69 using ClientHeartbeat=common::ClientHeartbeat;
70 using LogonReply=common::LogonReply<MsgType, MsgType::LogonReply>;
71 using Logout=common::Logout;
72 using ServerHeartbeat=common::ServerHeartbeat;
73 using ReplayComplete=common::ReplayComplete;
74 using NewOrder=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);
94 static inline constexpr MsgTypes_t Exit=static_cast<MsgTypes_t>(MsgType_t::Exit);
95
96 using client_to_exchange_messages_t=boost::mpl::vector<
97 LogonRequest,
98 LogoutRequest,
99 ClientHeartbeat,
100 NewOrder,
101 CancelOrder,
102 ModifyOrder
103 >;
104
105 using exchange_to_client_messages_t=boost::mpl::vector<
106 LogonReply,
107 Logout,
108 ServerHeartbeat,
109 ReplayComplete,
110 OrderAcknowledgement,
111 OrderRejected,
112 OrderModified,
113 OrderRestated,
114 UserModifyRejected,
115 OrderCancelled,
116 CancelRejected,
117 OrderExecution,
118 TradeCancelOrCorrect
119 >;
120
121 enum : std::size_t {
122 min_size_client_to_exchange_msg=sizeof(
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 ),
129 max_size_client_to_exchange_msg=sizeof(
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 ),
136 min_size_exchange_to_client_msg=sizeof(
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 ),
143 max_size_exchange_to_client_msg=sizeof(
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=jmmcg::min<std::size_t, min_size_client_to_exchange_msg, min_size_exchange_to_client_msg>::value,
151 max_msg_size=jmmcg::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>;
157 using client_to_exchange_messages_container=boost::make_variant_over<client_to_exchange_messages_t>::type;
158 using exchange_to_client_messages_container=boost::make_variant_over<exchange_to_client_messages_t>::type;
159
160 static inline constexpr Price_t implied_decimal_places=common::implied_decimal_places;
161
162 static std::ostream &to_stream(std::ostream &) noexcept(false);
163 };
164
165
166
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), ==, 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