root/isimud/exchanges/links/fix_to_mit_program_options_impl.hpp

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. create_program_options

   1 /******************************************************************************
   2 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/core/exchanges/links/fix_to_mit_main_impl.hpp 2118 2017-08-23 09:42:12Z jmmcg $
   3 **
   4 ** Copyright (c) 2017 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 namespace isimud { namespace exchanges { namespace MIT {
  22 
  23 template<class Link>
  24 inline boost::program_options::options_description
  25 create_program_options(boost::program_options::options_description &&all) noexcept(false) {
  26         using link_t=Link;
  27         using exchange_msg_details_t=typename link_t::exchange_msg_details_t;
  28         using socket_t=typename link_t::socket_t;
  29         using proc_rules_t=MIT::common::simulator_responses<exchange_msg_details_t, socket_t>;
  30 
  31         std::string const MIC_code=[]() {
  32                 std::ostringstream ss;
  33                 exchanges::common::mic_codes::to_stream<exchange_msg_details_t::MIC_code>(ss);
  34                 return ss.str();
  35         }();
  36         std::ostringstream os;
  37         std::string const details=os.str()+"\n"+[]() {
  38                 std::ostringstream ss;
  39                 ss<<"ISO 10383: MIC Codes official information: ";
  40                 decltype(+exchanges::common::mic_codes::collection[
  41                         boost::hana::int_c<
  42                                 static_cast<
  43                                         std::underlying_type<exchanges::common::mic_codes::ISO_10383_MIC_Codes>::type
  44                                 >(
  45                                         exchange_msg_details_t::MIC_code
  46                                 )
  47                         >
  48                 ])::type::to_stream(ss);
  49                 return ss.str();
  50         }();
  51 
  52         boost::program_options::options_description link_opts((MIC_code+" link options.").c_str());
  53         link_opts.add_options()
  54         (
  55                 (MIC_code+"_ref_data").c_str(),
  56                 boost::program_options::value<std::string>()->required(),
  57                 "The file-path of a file that contains the full reference-data supplied for the exchange, that must map ISINs to exchange-specific instrument IDs in CSV format separated by semicolons."
  58         );
  59         boost::program_options::options_description client("FIX-client options.");
  60         client.add_options()
  61         (
  62                 "client_address",
  63                 boost::program_options::value<std::string>()->required()->default_value(boost::asio::ip::address_v4::loopback().to_string()),
  64                 "IP address (in v4 format) to which the translator should listen."
  65         )
  66         (
  67                 "client_port",
  68                 boost::program_options::value<unsigned short>()->required(),
  69                 "An unused port to which the translator should listen."
  70         );
  71         boost::program_options::options_description exchange("Exchange options (the defaults are suitable for use with the simulator)");
  72         exchange.add_options()
  73         (
  74                 (MIC_code+"_primary_gateway_address").c_str(),
  75                 boost::program_options::value<std::string>()->required()->default_value(boost::asio::ip::address_v4::loopback().to_string()),
  76                 "IP address (in v4 format) of the primary gateway to which the translator should connect."
  77         )
  78         (
  79                 (MIC_code+"_primary_gateway_port").c_str(),
  80                 boost::program_options::value<unsigned short>()->required(),
  81                 "The port of the primary gateway to which the translator should connect."
  82         )
  83         (
  84                 (MIC_code+"_secondary_gateway_address").c_str(),
  85                 boost::program_options::value<std::string>()->required()->default_value(boost::asio::ip::address_v4::loopback().to_string()),
  86                 "IP address (in v4 format) of the secondary gateway to which the translator should connect."
  87         )
  88         (
  89                 (MIC_code+"_secondary_gateway_port").c_str(), 
  90                 boost::program_options::value<unsigned short>()->required(),
  91                 "The port of the secondary gateway to which the translator should connect."
  92         )
  93         (
  94                 (MIC_code+"_username").c_str(),
  95                 boost::program_options::value<std::string>()->required()->default_value(proc_rules_t::username.begin()),
  96                 "The username with which to connect to the exchange."
  97         )
  98         (
  99                 (MIC_code+"_password").c_str(),
 100                 boost::program_options::value<std::string>()->required()->default_value(proc_rules_t::password.begin()),
 101                 "The password with which to connect to the exchange."
 102         )
 103         (
 104                 (MIC_code+"_new_password").c_str(),
 105                 boost::program_options::value<std::string>()->required()->default_value(proc_rules_t::new_password.begin()),
 106                 "The new password with which to connect to the exchange."
 107         )
 108         (
 109                 (MIC_code+"_logout_reason").c_str(),
 110                 boost::program_options::value<std::string>()->required()->default_value("TTFN"),
 111                 "The reason that should be used when logging out of the connected exchange."
 112         );
 113         boost::program_options::options_description all_opts(details);
 114         all_opts.add(link_opts).add(client).add(exchange);
 115         all.add(all_opts);
 116         return all;
 117 }
 118 
 119 } } }

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