ORE Studio 0.0.4
Loading...
Searching...
No Matches
exporter.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 *
20 */
21#ifndef ORES_ORE_XML_EXPORTER_HPP
22#define ORES_ORE_XML_EXPORTER_HPP
23
24#include <string>
25#include <vector>
26#include <filesystem>
27#include "ores.logging/make_logger.hpp"
28#include "ores.refdata.api/domain/currency.hpp"
29#include "ores.refdata.api/domain/calendar_adjustment.hpp"
30#include "ores.trading.api/messaging/trade_protocol.hpp"
31#include "ores.ore/domain/conventions_mapper.hpp"
32
33namespace ores::ore::xml {
34
35struct roundtrip_summary {
36 int total_xml_files = 0;
37 int skipped = 0;
38 int output_files_written = 0;
39 int trades_mapped = 0;
40 int trades_passthrough = 0;
41 int currency_files = 0;
42 int calendar_files = 0;
43 int convention_files = 0;
44 long long import_ms = 0;
45 long long export_ms = 0;
46 long long total_ms = 0;
47};
48
52class exporter {
53private:
54 inline static std::string_view logger_name = "ores.ore.xml.exporter";
55
56 static auto& lg() {
57 using namespace ores::logging;
58 static auto instance = make_logger(logger_name);
59 return instance;
60 }
61
62public:
63 static std::string
64 export_currency_config(const std::vector<refdata::domain::currency>& v);
65
66 static std::string export_calendar_adjustments(
67 const std::vector<refdata::domain::calendar_adjustment>& v);
68
69 static std::string export_conventions(
71
79 static std::string export_portfolio(
80 const std::vector<trading::messaging::trade_export_item>& items);
81
89 static roundtrip_summary roundtrip(
90 const std::filesystem::path& input_dir,
91 const std::filesystem::path& output_dir);
92};
93
94}
95
96#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Provides XML serialisation support for ORE types.
Definition exporter.hpp:33
All convention types extracted from a single ORE conventions.xml file.
Definition conventions_mapper.hpp:46
Exports domain objects to their ORE XML representation.
Definition exporter.hpp:52
static roundtrip_summary roundtrip(const std::filesystem::path &input_dir, const std::filesystem::path &output_dir)
Walks input_dir recursively, roundtrips every supported ORE XML through the import→export pipeline,...
Definition exporter.cpp:406
static std::string export_portfolio(const std::vector< trading::messaging::trade_export_item > &items)
Reconstructs an ORE portfolio XML from a vector of (trade, instrument) pairs returned by export_portf...
Definition exporter.cpp:102