libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
fix_client.hpp
Go to the documentation of this file.
1 #ifndef ISIMUD_EXCHANGES_FIX_v5_0sp2_FIX_CLIENT_HPP
2 #define ISIMUD_EXCHANGES_FIX_v5_0sp2_FIX_CLIENT_HPP
3 /******************************************************************************
4 ** Copyright © 2019 by J.M.McGuiness, isimud@hussar.me.uk
5 **
6 ** This library is free software; you can redistribute it and/or
7 ** modify it under the terms of the GNU Lesser General Public
8 ** License as published by the Free Software Foundation; either
9 ** version 2.1 of the License, or (at your option) any later version.
10 **
11 ** This library is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** Lesser General Public License for more details.
15 **
16 ** You should have received a copy of the GNU Lesser General Public
17 ** License along with this library; if not, write to the Free Software
18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 
21 #include "fix.hpp"
22 
23 #include "core/application.hpp"
24 #include "core/ave_deviation_meter.hpp"
25 #include "core/latency_timestamps.hpp"
26 #include "core/socket_wrapper.hpp"
27 
28 namespace isimud { namespace ISIMUD_VER_NAMESPACE { namespace exchanges { namespace FIX { namespace v5_0sp2 {
29 
30 class fix_client : public libjmmcg::application {
31 public:
32  using base_t=libjmmcg::application;
33  using timed_results_t=libjmmcg::ave_deviation_meter<double>;
34 
35  ALIGN_TO_L1_CACHE static inline constexpr const FIX::common::underlying_fix_data_buffer fix_buffer={
36  "8=FIX.5.0\0019=154\00135=D\00134=10\00143=N\00149=VENDOR\00150=CUSTOME\00156=BROKER\00160=19980930-09:25:58\0011=XQCCFUND\00111=10\00121=1\00155=EK\00148=GB0000595859\00122=4\00154=1\00138=10000\00140=2\00144=76.750000\00159=0\00110=092\001"
37  };
38  static inline MsgTypes::NewOrderSingle const &send_fix_msg=reinterpret_cast<MsgTypes::NewOrderSingle const &>(*fix_buffer.begin());
39  MsgTypes::BusinessMessageReject receive_fix_msg;
40 
41  fix_client(boost::asio::ip::address const &addr, unsigned short port_num, libjmmcg::socket::socket_priority priority, std::size_t incoming_cpu, libjmmcg::latency_timestamps_itf &ts) noexcept(false);
42 
43  void send() noexcept(false);
44  void receive() noexcept(false);
45 
46  void in_order_tx_rx(unsigned long num_loops) noexcept(false);
47  std::pair<timed_results_t, bool> in_order_tx_rx_stats(unsigned long num_loops, unsigned short loops_for_conv, double perc_conv_estimate) noexcept(false);
48 
49  friend std::ostream&
50  operator<<(std::ostream &os, fix_client const &fc) noexcept(false);
51 
52 private:
53  connection_t client;
54  libjmmcg::latency_timestamps_itf &timestamps;
55 };
56 
57 } } } } }
58 
59 #include "fix_client_impl.hpp"
60 
61 #endif