ORE Studio 0.0.4
Loading...
Searching...
No Matches
ImportTradeDialog.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_QT_IMPORT_TRADE_DIALOG_HPP
21#define ORES_QT_IMPORT_TRADE_DIALOG_HPP
22
23#include <atomic>
24#include <vector>
25#include <QString>
26#include <QDialog>
27#include <QLabel>
28#include <QWidget>
29#include <QCheckBox>
30#include <QDateEdit>
31#include <QLineEdit>
32#include <QPushButton>
33#include <QComboBox>
34#include <QTableWidget>
35#include <QProgressBar>
36#include <QFutureWatcher>
37#include <boost/uuid/uuid.hpp>
38#include "ores.ore/xml/importer.hpp"
39#include "ores.refdata.api/domain/book.hpp"
40#include "ores.refdata.api/domain/counterparty.hpp"
41#include "ores.qt/ClientManager.hpp"
42#include "ores.logging/make_logger.hpp"
43
44namespace ores::qt {
45
57class ImportTradeDialog final : public QDialog {
58 Q_OBJECT
59
60private:
61 inline static std::string_view logger_name =
62 "ores.qt.import_trade_dialog";
63
64 [[nodiscard]] static auto& lg() {
65 using namespace ores::logging;
66 static auto instance = make_logger(logger_name);
67 return instance;
68 }
69
70public:
83 explicit ImportTradeDialog(
84 const refdata::domain::book& book,
85 const std::vector<ore::xml::trade_import_item>& items,
86 const QString& source_label,
87 const std::string& market_data_dir,
88 ClientManager* clientManager,
89 const QString& username,
90 QWidget* parent = nullptr);
91
92 ~ImportTradeDialog() override;
93
94signals:
100 void importCompleted(int success_count, int total_count);
101
106
107private slots:
108 void onImportClicked();
109 void onCancelClicked();
110 void onSelectAllChanged(Qt::CheckState state);
111 void onTradeCheckChanged();
112 void onApplyNettingSetToAll();
113 void onApplyCounterpartyToAll();
114
115private:
116 void setupUI();
117 void populateTradeTable();
118 void populateCounterpartyCombos();
119 void loadCounterparties();
120 void updateImportButtonState();
121 void updateSelectionCount();
122
123private:
125 std::vector<ore::xml::trade_import_item> items_;
126 std::vector<std::string> validation_errors_;
127 std::vector<refdata::domain::counterparty> counterparties_;
128 QString source_label_;
129 std::string market_data_dir_;
130 ClientManager* clientManager_;
131 QString username_;
132
133 // Import defaults
134 QDateEdit* tradeDateEdit_;
135 QDateEdit* effectiveDateEdit_;
136 QDateEdit* terminationDateEdit_;
137 QComboBox* lifecycleEventCombo_;
138 QLineEdit* defaultNettingSetEdit_;
139 QComboBox* defaultCounterpartyCombo_;
140 QLabel* counterpartyStatusLabel_;
141
142 // Trade table and controls
143 QLabel* fileLabel_;
144 QLabel* bookLabel_;
145 QCheckBox* selectAllCheckbox_;
146 QLabel* selectionCountLabel_;
147 QTableWidget* tradeTable_;
148
149 // Progress and status
150 QProgressBar* progressBar_;
151 QLabel* statusLabel_;
152 QPushButton* importButton_;
153 QPushButton* cancelButton_;
154
155 bool importInProgress_;
156 std::atomic<bool> cancelRequested_;
157};
158
159}
160
161#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:123
Dialog for reviewing defaults and importing ORE portfolio trades.
Definition ImportTradeDialog.hpp:57
void importCompleted(int success_count, int total_count)
Emitted when import completes.
void importCancelled()
Emitted when import is cancelled.
Operational ledger leaf that holds trades.
Definition book.hpp:37