20#ifndef ORES_QT_PORTFOLIO_EXPLORER_TRADE_MODEL_HPP
21#define ORES_QT_PORTFOLIO_EXPLORER_TRADE_MODEL_HPP
26#include <unordered_map>
27#include <QFutureWatcher>
28#include <QAbstractTableModel>
29#include <boost/uuid/uuid.hpp>
30#include "ores.logging/make_logger.hpp"
31#include "ores.qt/ClientManager.hpp"
32#include "ores.trading.api/domain/trade.hpp"
33#include "ores.trading.api/messaging/trade_protocol.hpp"
41 std::string short_code;
42 std::string full_name;
55 inline static std::string_view logger_name =
56 "ores.qt.portfolio_explorer_trade_model";
58 [[nodiscard]]
static auto& lg() {
60 static auto instance = make_logger(logger_name);
68 CounterpartyShortCode,
81 QObject* parent =
nullptr);
85 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
86 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
87 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
88 QVariant headerData(
int section, Qt::Orientation orientation,
89 int role = Qt::DisplayRole)
const override;
94 void set_filter(std::optional<boost::uuids::uuid> book_id,
95 std::optional<boost::uuids::uuid> portfolio_id);
101 std::unordered_map<std::string, CounterpartyInfo> cpty_map);
111 void load_page(std::uint32_t offset, std::uint32_t limit);
125 void loadError(
const QString& error_message,
const QString& details = {});
128 void onTradesLoaded();
133 std::vector<trading::domain::trade> trades;
134 std::uint32_t total_available_count;
135 QString error_message;
136 QString error_details;
139 void fetch_trades(std::uint32_t offset, std::uint32_t limit);
141 ClientManager* clientManager_;
142 std::vector<trading::domain::trade> items_;
143 QFutureWatcher<FetchResult>* watcher_;
144 std::uint32_t total_available_count_{0};
145 bool is_fetching_{
false};
147 std::optional<boost::uuids::uuid> filter_book_id_;
148 std::optional<boost::uuids::uuid> filter_portfolio_id_;
149 std::unordered_map<std::string, CounterpartyInfo> cpty_map_;
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
Short counterparty display info.
Definition PortfolioExplorerTradeModel.hpp:40
Table model for filtered trades in the portfolio/book tree window.
Definition PortfolioExplorerTradeModel.hpp:51
const trading::domain::trade * get_trade(int row) const
Get the trade at the given row.
Definition PortfolioExplorerTradeModel.cpp:253
void refresh()
Refresh trade data from server using current filter.
Definition PortfolioExplorerTradeModel.cpp:149
std::uint32_t total_available_count() const
Get total available count from last fetch.
Definition PortfolioExplorerTradeModel.hpp:116
void set_counterparty_map(std::unordered_map< std::string, CounterpartyInfo > cpty_map)
Set the counterparty lookup map (UUID string -> CounterpartyInfo).
Definition PortfolioExplorerTradeModel.cpp:139
void load_page(std::uint32_t offset, std::uint32_t limit)
Load a specific page.
Definition PortfolioExplorerTradeModel.cpp:171
void set_filter(std::optional< boost::uuids::uuid > book_id, std::optional< boost::uuids::uuid > portfolio_id)
Set book/portfolio filter and clear existing data.
Definition PortfolioExplorerTradeModel.cpp:132
Trade capturing FpML Trade Header properties.
Definition trade.hpp:39