libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
mit_reference_data.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2015 by J.M.McGuiness, isimud@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 #include "stdafx.h"
20 
21 #define BOOST_TEST_MODULE isimud_tests
22 #include <boost/test/included/unit_test.hpp>
23 
24 #include "../exchanges/MIT/common/ref_data.hpp"
25 
26 using namespace libisimud;
27 
28 using ref_data_t=exchanges::MIT::common::ref_data;
29 
30 BOOST_AUTO_TEST_SUITE(market_data)
31 
32 BOOST_AUTO_TEST_CASE(ctor) {
33  std::stringstream ss;
34  const ref_data_t ref_data(ss);
35  BOOST_CHECK(ref_data.lookup_instrument_id().empty());
36  BOOST_CHECK(ref_data.lookup_isin().empty());
37 }
38 
39 BOOST_AUTO_TEST_CASE(one_entry) {
40  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;;;;;;");
41  std::stringstream ss;
42  ss<<ref_data_file;
43  const ref_data_t ref_data(ss);
44  BOOST_CHECK(!ref_data.lookup_instrument_id().empty());
45  BOOST_CHECK_EQUAL(ref_data.lookup_instrument_id().size(), 1);
46  BOOST_CHECK(!ref_data.lookup_isin().empty());
47  BOOST_CHECK_EQUAL(ref_data.lookup_isin().size(), 1);
48  const typename ref_data_t::security_id_key sik(exchanges::common::ISIN_t("GB00BH4HKS39"));
49  BOOST_CHECK_EQUAL(sik.isin_.hash(), 124731814251123);
50  BOOST_CHECK(ref_data.lookup_instrument_id().find(sik)!=ref_data.lookup_instrument_id().end());
51  BOOST_CHECK_EQUAL(ref_data.lookup_instrument_id().find(sik)->second, 133215);
52  BOOST_CHECK(ref_data.lookup_isin().find(133215)!=ref_data.lookup_isin().end());
53  BOOST_CHECK_EQUAL(ref_data.lookup_isin().find(133215)->second, sik);
54 }
55 
56 BOOST_AUTO_TEST_CASE(two_entries) {
57  const std::string ref_data_file(
58  "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;;;;;;\n"
59  "2926;FTSE100;SET1;PT_T;TP_12;GB0000595859;;20000419;0;1;3000;32438040;1;;1;DE;ARM;ARM HLDGS.;0059585;3861344694;GBX;1;Y;0023;ARARM;ARM HOLDINGS PLC;0;;;7500;ORD 0.05P;;1;1;5;GB;;;FS10;4;;;;2;B;;;;;;"
60  );
61  std::stringstream ss;
62  ss<<ref_data_file;
63  const ref_data_t ref_data(ss);
64  BOOST_CHECK(!ref_data.lookup_instrument_id().empty());
65  BOOST_CHECK_EQUAL(ref_data.lookup_instrument_id().size(), 2);
66  BOOST_CHECK_EQUAL(ref_data.lookup_isin().size(), 2);
67  const typename ref_data_t::security_id_key sik1(exchanges::common::ISIN_t("GB00BH4HKS39"));
68  BOOST_CHECK(ref_data.lookup_instrument_id().find(sik1)!=ref_data.lookup_instrument_id().end());
69  BOOST_CHECK_EQUAL(ref_data.lookup_instrument_id().find(sik1)->second, 133215);
70  BOOST_CHECK(ref_data.lookup_isin().find(133215)!=ref_data.lookup_isin().end());
71  BOOST_CHECK_EQUAL(ref_data.lookup_isin().find(133215)->second, sik1);
72  const typename ref_data_t::security_id_key sik2(exchanges::common::ISIN_t("GB0000595859"));
73  BOOST_CHECK(ref_data.lookup_instrument_id().find(sik2)!=ref_data.lookup_instrument_id().end());
74  BOOST_CHECK_NE(sik1.isin_.hash(), sik2.isin_.hash());
75  BOOST_CHECK_EQUAL(ref_data.lookup_instrument_id().find(sik2)->second, 2926);
76  BOOST_CHECK(ref_data.lookup_isin().find(2926)!=ref_data.lookup_isin().end());
77  BOOST_CHECK_EQUAL(ref_data.lookup_isin().find(2926)->second, sik2);
78 }
79 
80 BOOST_AUTO_TEST_SUITE_END()