root/isimud/tests/mit_to_fix.cpp

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

DEFINITIONS

This source file includes following definitions.
  1. BOOST_AUTO_TEST_SUITE
  2. BOOST_AUTO_TEST_CASE_TEMPLATE
  3. BOOST_AUTO_TEST_CASE_TEMPLATE
  4. BOOST_AUTO_TEST_CASE_TEMPLATE
  5. BOOST_AUTO_TEST_CASE_TEMPLATE

   1 /******************************************************************************

   2 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/isimud/tests/mit_to_fix.cpp 2261 2018-02-23 07:53:58Z jmmcg $

   3 **

   4 ** Copyright (c) 2015 by J.M.McGuiness, coder@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 "stdafx.h"
  22 
  23 #define BOOST_TEST_MODULE libjmmcg_tests
  24 #include <boost/test/included/unit_test.hpp>
  25 
  26 #include <boost/test/test_case_template.hpp>
  27 #include <boost/mpl/list.hpp>
  28 
  29 #include "../exchanges/conversions/mit_to_fix_conversions.hpp"
  30 
  31 const int32_t seqNum=1;
  32 const isimud::exchanges::MIT::common::ClientOrderID_t clientOrderId1{"abcdefghijklm0test1"};
  33 const isimud::exchanges::MIT::common::AppID aID=isimud::exchanges::MIT::common::AppID::Partition1;
  34 const isimud::exchanges::MIT::common::ExecType eT=isimud::exchanges::MIT::common::ExecType::New;
  35 const isimud::exchanges::MIT::common::Price_t price=42*isimud::exchanges::MIT::common::implied_decimal_places;
  36 const isimud::exchanges::MIT::common::SecurityID_t instID=133215;
  37 const isimud::exchanges::MIT::common::Side s=isimud::exchanges::MIT::common::Side::Buy;
  38 
  39 typedef boost::mpl::list<
  40         std::pair<isimud::exchanges::MIT::BIT::MsgTypes, isimud::exchanges::MIT::BIT::MsgTypes::ref_data>,
  41         std::pair<isimud::exchanges::MIT::JSE::MsgTypes, isimud::exchanges::MIT::JSE::MsgTypes::ref_data>,
  42         std::pair<isimud::exchanges::MIT::LSE::MsgTypes, isimud::exchanges::MIT::LSE::MsgTypes::ref_data>,
  43         std::pair<isimud::exchanges::MIT::OSLO::MsgTypes, isimud::exchanges::MIT::OSLO::MsgTypes::ref_data>,
  44         std::pair<isimud::exchanges::MIT::TRQ::MsgTypes, isimud::exchanges::MIT::TRQ::MsgTypes::ref_data>
  45 > msg_types;
  46 
  47 BOOST_AUTO_TEST_SUITE(exchanges)
  48 
  49 BOOST_AUTO_TEST_CASE_TEMPLATE(ExecutionReport, msg, msg_types) {
  50         typename msg::first_type::ExecutionReport exchg_msg(seqNum, clientOrderId1, aID, eT, price, instID, s);
  51         exchg_msg.orderStatus_=isimud::exchanges::MIT::common::OrderStatus::Rejected;
  52         exchg_msg.executedQty(0);
  53         exchg_msg.leavesQty(0);
  54         const std::string ref_data_file("133215;FTSE100;SET0;PT_T;TP_1;GB00BH4HKS39;;20060731;0;1;10000;42467000;1;;1;DE;VOD;VODAFONE GRP.;BH4HKS3;15225662730;GBX;1;Y;0023;VOVOD;VODAFONE GROUP PLC;0;;;15000;ORD USD0.20 20/21;;1;1;5;GB;;;FE00;1;;;;1;A;;;;;;");
  55         std::stringstream ss;
  56         ss<<ref_data_file;
  57         const typename msg::second_type ref_data(ss);
  58         const isimud::exchanges::FIX::v5_0sp2::MsgTypes::ExecutionReport fix_msg(exchg_msg, ref_data);
  59         BOOST_CHECK(fix_msg.is_valid());
  60         auto const client_order_id=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::ClOrdID>();
  61         BOOST_CHECK_EQUAL(std::string(client_order_id.first, client_order_id.second), clientOrderId1.begin());
  62         auto const exec_type=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::ExecType>();
  63         BOOST_CHECK_EQUAL(static_cast<isimud::exchanges::FIX::common::ExecType>(*exec_type.first), isimud::exchanges::FIX::common::convert(eT));
  64         auto const fix_price=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::Price>();
  65         BOOST_CHECK_EQUAL(static_cast<isimud::exchanges::MIT::common::Price_t>(jmmcg::fromstring<double>(fix_price.first, fix_price.second-fix_price.first)), price/isimud::exchanges::MIT::common::implied_decimal_places);
  66         auto const sec_id_type=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::SecurityIDSource>();
  67         BOOST_CHECK_EQUAL(std::string(sec_id_type.first, sec_id_type.second), "4");
  68         auto const symbol=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::SecurityID>();
  69         BOOST_CHECK_EQUAL(std::string(symbol.first, symbol.second), "GB00BH4HKS39");
  70         auto const ordStatus=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::OrdStatus>();
  71         BOOST_CHECK_EQUAL(static_cast<isimud::exchanges::FIX::common::OrdStatus>(*ordStatus.first), isimud::exchanges::FIX::common::OrdStatus::Rejected);
  72         auto const orderQty=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::OrderQty>();
  73         BOOST_CHECK_EQUAL(std::string(orderQty.first, orderQty.second), "0");
  74         auto const leavesQty=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::LeavesQty>();
  75         BOOST_CHECK_EQUAL(std::string(leavesQty.first, leavesQty.second), "0");
  76         auto const side=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::Side>();
  77         BOOST_CHECK_EQUAL(std::string(side.first, side.second), "1");
  78 }
  79 
  80 BOOST_AUTO_TEST_CASE_TEMPLATE(reject, msg, msg_types) {
  81         typename msg::first_type::Reject exchg_msg(clientOrderId1, static_cast<typename msg::first_type::Reject::RejectCode_t>(2004));
  82         const isimud::exchanges::FIX::v5_0sp2::MsgTypes::OrderRejected fix_msg(exchg_msg);
  83         BOOST_CHECK(fix_msg.is_valid());
  84 }
  85 
  86 BOOST_AUTO_TEST_CASE_TEMPLATE(order_reject, msg, msg_types) {
  87         typename msg::first_type::ExecutionReport exchg_msg(seqNum, clientOrderId1, aID, eT, price, instID, s);
  88         exchg_msg.orderRejectCode(static_cast<typename msg::first_type::Reject::RejectCode_t>(2004));
  89         exchg_msg.orderStatus(isimud::exchanges::MIT::common::OrderStatus::Rejected);
  90         const isimud::exchanges::FIX::v5_0sp2::MsgTypes::OrderRejected fix_msg(exchg_msg);
  91         BOOST_CHECK(fix_msg.is_valid());
  92         auto const ref_seq_num=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::RefSeqNum>();
  93         BOOST_CHECK_EQUAL(std::string(ref_seq_num.first, ref_seq_num.second), "1");
  94 }
  95 
  96 BOOST_AUTO_TEST_CASE_TEMPLATE(BusinessReject, msg, msg_types) {
  97         typename msg::first_type::BusinessReject exchg_msg(seqNum, clientOrderId1);
  98         exchg_msg.rejectCode(static_cast<typename msg::first_type::BusinessReject::RejectCode_t>(9000));
  99         const isimud::exchanges::FIX::v5_0sp2::MsgTypes::BusinessMessageReject fix_msg(exchg_msg);
 100         BOOST_CHECK(fix_msg.is_valid());
 101         auto const ref_seq_num=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::RefSeqNum>();
 102         BOOST_CHECK_EQUAL(std::string(ref_seq_num.first, ref_seq_num.second), "1");
 103 }
 104 
 105 BOOST_AUTO_TEST_CASE_TEMPLATE(OrderCancelReject, msg, msg_types) {
 106         typename msg::first_type::OrderCancelReject exchg_msg(seqNum, clientOrderId1);
 107         exchg_msg.cancelRejectReason(static_cast<typename msg::first_type::Reject::RejectCode_t>(2004));
 108         const isimud::exchanges::FIX::v5_0sp2::MsgTypes::CancelRejected fix_msg(exchg_msg);
 109         BOOST_CHECK(fix_msg.is_valid());
 110         auto const client_order_id=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::ClOrdID>();
 111         BOOST_CHECK_EQUAL(std::string(client_order_id.first, client_order_id.second), clientOrderId1.begin());
 112         auto const order_id=fix_msg.find<isimud::exchanges::FIX::common::FieldsFast::OrderID>();
 113 // TODO BOOST_CHECK_EQUAL(std::string(order_id.first, order_id.second), clientOrderId1.begin());

 114 }
 115 
 116 BOOST_AUTO_TEST_SUITE_END()

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