root/isimud/exchanges/BATSBOE/EU/v1/messages.hpp

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef libjmmcg_isimud_exchanges_BATSBOE_EU_v1_messages_hpp
   2 #define libjmmcg_isimud_exchanges_BATSBOE_EU_v1_messages_hpp
   3 
   4 /******************************************************************************
   5 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/isimud/exchanges/BATSBOE/EU/v1/messages.hpp 2350 2018-10-14 18:34:26Z jmmcg $
   6 **
   7 ** Copyright (c) 2015 by J.M.McGuiness, isimud@hussar.me.uk
   8 **
   9 ** This library is free software; you can redistribute it and/or
  10 ** modify it under the terms of the GNU Lesser General Public
  11 ** License as published by the Free Software Foundation; either
  12 ** version 2.1 of the License, or (at your option) any later version.
  13 **
  14 ** This library is distributed in the hope that it will be useful,
  15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17 ** Lesser General Public License for more details.
  18 **
  19 ** You should have received a copy of the GNU Lesser General Public
  20 ** License along with this library; if not, write to the Free Software
  21 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22 */
  23 
  24 #include "config.h"
  25 #include "../messages.hpp"
  26 
  27 #include "core/max_min.hpp"
  28 
  29 #include <boost/mpl/max_element.hpp>
  30 #include <boost/mpl/min_element.hpp>
  31 #include <boost/mpl/vector.hpp>
  32 #include <boost/variant/variant.hpp>
  33 
  34 #include <iostream>
  35 
  36 namespace isimud { namespace exchanges { namespace BATSBOE { namespace EU {
  37 
  38 /**
  39         From <a href="http://cdn.batstrading.com/resources/participant_resources/BATS_Europe_Binary_Order_Entry_Specification.pdf">"BATS Chi-X Europe Binary Order Entry Specification", Version 1.44, 27 November, 2014</a>.
  40 */
  41 namespace v1 {
  42 
  43 struct MsgTypes {
  44 
  45         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_KINGDOM_BATE;
  46 
  47         struct ref_data {};
  48         using ref_data_t=ref_data const &;
  49 
  50         using MsgTypes_t=common::MsgType_t;
  51         using MsgType_t=common::MsgType;
  52         using UserName_t=common::UserName_t;
  53         using Password_t=common::Password_t;
  54         using SecurityID_t=common::SecurityID_t;
  55         using Price_t=common::Price_t;
  56         using ClientOrderID_t=common::ClientOrderID_t;
  57         using OrderType=common::OrdType;
  58         using Side=common::Side;
  59         using OrderRejectReason=common::OrderRejectReason;
  60         using LoginResponseStatus=common::LoginResponseStatus;
  61         using logon_args_t=common::logon_args_t;
  62 
  63         using LogonRequest=common::LogonRequest<MsgType, MsgType::LogonRequest>;
  64         using Header_t=LogonRequest::Header_t;
  65         using LogoutRequest=common::LogoutRequest;
  66         using ClientHeartbeat=common::ClientHeartbeat;
  67         using LogonReply=common::LogonReply<MsgType, MsgType::LogonReply>;
  68         using Logout=common::Logout;
  69         using ServerHeartbeat=common::ServerHeartbeat;
  70         using ReplayComplete=common::ReplayComplete;
  71         using NewOrder=common::NewOrder;
  72         using CancelOrder=common::CancelOrder;
  73         using ModifyOrder=common::ModifyOrder;
  74         using TradeCaptureReport=EU::TradeCaptureReport;
  75         using OrderAcknowledgement=common::OrderAcknowledgement;
  76         using OrderRejected=common::OrderRejected;
  77         using OrderModified=common::OrderModified;
  78         using OrderRestated=common::OrderRestated;
  79         using UserModifyRejected=common::UserModifyRejected;
  80         using OrderCancelled=common::OrderCancelled;
  81         using CancelRejected=common::CancelRejected;
  82         using OrderExecution=common::OrderExecution;
  83         using TradeCancelOrCorrect=common::TradeCancelOrCorrect;
  84         using TradeCaptureReportAck=EU::TradeCaptureReportAck;
  85         using TradeCaptureReportReject=EU::TradeCaptureReportReject;
  86         using TradeCaptureConfirm=EU::TradeCaptureConfirm;
  87         using TradeCaptureDecline=EU::TradeCaptureDecline;
  88 
  89         using ExecutionReport=OrderExecution;
  90         using Heartbeat=ClientHeartbeat;
  91         using OrderCancelRequest=CancelOrder;
  92         using OrderCancelReject=CancelRejected;
  93         using OrderCancelReplaceRequest=ModifyOrder;
  94 
  95         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.
  96         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.
  97 
  98         using client_to_exchange_messages_t=boost::mpl::vector<
  99                 LogonRequest,
 100                 LogoutRequest,
 101                 ClientHeartbeat,
 102                 NewOrder,
 103                 CancelOrder,
 104                 ModifyOrder,
 105                 TradeCaptureReport
 106         >;
 107 
 108         using exchange_to_client_messages_t=boost::mpl::vector<
 109                 LogonReply,
 110                 Logout,
 111                 ServerHeartbeat,
 112                 ReplayComplete,
 113                 OrderAcknowledgement,
 114                 OrderRejected,
 115                 OrderModified,
 116                 OrderRestated,
 117                 UserModifyRejected,
 118                 OrderCancelled,
 119                 CancelRejected,
 120                 OrderExecution,
 121                 TradeCancelOrCorrect,
 122                 TradeCaptureReportAck,
 123                 TradeCaptureReportReject,
 124                 TradeCaptureConfirm,
 125                 TradeCaptureDecline
 126         >;
 127 
 128         enum : std::size_t {
 129                 min_size_client_to_exchange_msg=sizeof(
 130                         boost::mpl::deref<
 131                                 boost::mpl::min_element<
 132                                         boost::mpl::transform_view<client_to_exchange_messages_t, boost::mpl::sizeof_<boost::mpl::_1> >
 133                                 >::type::base
 134                         >::type
 135                 ),
 136                 max_size_client_to_exchange_msg=sizeof(
 137                         boost::mpl::deref<
 138                                 boost::mpl::max_element<
 139                                         boost::mpl::transform_view<client_to_exchange_messages_t, boost::mpl::sizeof_<boost::mpl::_1> >
 140                                 >::type::base
 141                         >::type
 142                 ),
 143                 min_size_exchange_to_client_msg=sizeof(
 144                         boost::mpl::deref<
 145                                 boost::mpl::min_element<
 146                                         boost::mpl::transform_view<exchange_to_client_messages_t, boost::mpl::sizeof_<boost::mpl::_1> >
 147                                 >::type::base
 148                         >::type
 149                 ),
 150                 max_size_exchange_to_client_msg=sizeof(
 151                         boost::mpl::deref<
 152                                 boost::mpl::max_element<
 153                                         boost::mpl::transform_view<exchange_to_client_messages_t, boost::mpl::sizeof_<boost::mpl::_1> >
 154                                 >::type::base
 155                         >::type
 156                 ),
 157                 min_msg_size=jmmcg::min<std::size_t, min_size_client_to_exchange_msg, min_size_exchange_to_client_msg>::value,
 158                 max_msg_size=jmmcg::max<std::size_t, max_size_client_to_exchange_msg, max_size_exchange_to_client_msg>::value,
 159                 header_t_size=sizeof(typename LogonRequest::Header_t)
 160         };
 161         BOOST_MPL_ASSERT_RELATION(max_msg_size, >=, header_t_size);
 162 
 163         using msg_buffer_t=std::array<std::uint8_t, max_msg_size>;
 164         using client_to_exchange_messages_container=boost::make_variant_over<client_to_exchange_messages_t>::type;
 165         using exchange_to_client_messages_container=boost::make_variant_over<exchange_to_client_messages_t>::type;
 166 
 167         static inline constexpr Price_t implied_decimal_places=common::implied_decimal_places;
 168 
 169         static std::ostream &to_stream(std::ostream &) noexcept(false);
 170 };
 171 
 172 /**
 173         \test BATSBOE EU v1 size tests.
 174 */
 175 namespace tests {
 176 
 177 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogoutRequest), <=, MsgTypes::max_size_client_to_exchange_msg);
 178 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogoutRequest), <=, MsgTypes::max_size_exchange_to_client_msg);
 179 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogoutRequest), <=, MsgTypes::max_msg_size);
 180 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogonRequest), ==, 261);
 181 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogoutRequest), ==, 10);
 182 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::ClientHeartbeat), ==, 10);
 183 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::LogonReply), ==, 11);
 184 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::Logout), ==, 76);
 185 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::ServerHeartbeat), ==, 10);
 186 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::ReplayComplete), ==, 10);
 187 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::NewOrder), ==, 157);
 188 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::CancelOrder), ==, 36);
 189 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::ModifyOrder), ==, 73);
 190 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::TradeCaptureReport), ==, 133);
 191 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderAcknowledgement), ==, 245);
 192 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderRejected), ==, 213);
 193 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderModified), ==, 205);
 194 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderRestated), ==, 216);
 195 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::UserModifyRejected), ==, 108);
 196 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderCancelled), ==, 191);
 197 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::CancelRejected), ==, 100);
 198 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::OrderExecution), ==, 215);
 199 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::TradeCancelOrCorrect), ==, 170);
 200 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::TradeCaptureReportAck), ==, 185);
 201 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::TradeCaptureReportReject), ==, 246);
 202 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::TradeCaptureConfirm), ==, 290);
 203 BOOST_MPL_ASSERT_RELATION(sizeof(MsgTypes::TradeCaptureDecline), ==, 290);
 204 
 205 }
 206 
 207 } } } } }
 208 
 209 #include "messages_impl.hpp"
 210 
 211 #endif

/* [<][>][^][v][top][bottom][index][help] */