20#ifndef ORES_QT_SWAP_INSTRUMENT_FORM_HPP
21#define ORES_QT_SWAP_INSTRUMENT_FORM_HPP
27#include <boost/uuid/uuid.hpp>
28#include "ores.qt/IInstrumentForm.hpp"
29#include "ores.logging/make_logger.hpp"
30#include "ores.trading.api/domain/swap_leg.hpp"
33class SwapInstrumentForm;
50 inline static std::string_view logger_name =
"ores.qt.swap_instrument_form";
52 [[nodiscard]]
static auto& lg() {
54 static auto instance = make_logger(logger_name);
71 boost::uuids::uuid instrument_id;
72 std::optional<boost::uuids::uuid> trade_id;
74 std::string trade_type_code;
77 std::string start_date;
78 std::string maturity_date;
79 std::string description;
83 double notional = 0.0;
84 std::string rate_index;
86 std::string long_short;
89 std::optional<int> lockout_days;
92 std::string call_dates_json;
93 std::string call_type;
96 std::string reference_counterparty;
97 double participation_rate = 0.0;
98 std::optional<double> protection_fee;
101 std::string inflation_index_code;
102 std::optional<double> base_cpi;
103 std::string lag_convention;
107 std::string modified_by;
108 std::string performed_by;
109 std::chrono::system_clock::time_point recorded_at;
110 std::string change_reason_code;
111 std::string change_commentary;
118 void setUsername(
const std::string& username)
override;
122 const trading::domain::trade_instrument& instrument)
override;
123 void clear()
override;
126 bool has_options,
bool has_extension)
override;
133 const std::string& code,
const std::string& commentary)
override;
137 std::function<
void(
const std::string&
id)> on_success,
138 std::function<
void(
const QString& error)> on_failure)
override;
141 void setupConnections();
142 void populateCurrencies();
143 void populateFromState();
144 void emitProvenance();
145 void onFieldChanged();
147 Ui::SwapInstrumentForm* ui_;
150 std::string username_;
152 std::vector<trading::domain::swap_leg> legs_;
154 bool loaded_ =
false;
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
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:54
Pure-virtual interface implemented by every per-family instrument form widget hosted in TradeDetailDi...
Definition IInstrumentForm.hpp:73
IInstrumentForm subclass owning the swap / rates instrument editor.
Definition SwapInstrumentForm.hpp:46
void saveInstrument(std::function< void(const std::string &id)> on_success, std::function< void(const QString &error)> on_failure) override
Save the in-flight instrument via the family's NATS request.
Definition SwapInstrumentForm.cpp:554
bool isLoaded() const override
True after the asynchronous load has populated the form.
Definition SwapInstrumentForm.cpp:433
void setInstrument(const trading::domain::trade_instrument &instrument) override
Populate the form with the already-resolved instrument.
Definition SwapInstrumentForm.cpp:472
void writeUiToInstrument() override
Pull the current UI values into the in-flight domain object.
Definition SwapInstrumentForm.cpp:441
void setImageCache(ImageCache *cache) override
Inject the image cache for flag icons on currency combo boxes.
Definition SwapInstrumentForm.cpp:361
void setUsername(const std::string &username) override
Inject the username stamped on every saved instrument.
Definition SwapInstrumentForm.cpp:395
void setTradeType(const QString &code, bool has_options, bool has_extension) override
Inform the form which trade type is currently selected.
Definition SwapInstrumentForm.cpp:409
void setChangeReason(const std::string &code, const std::string &commentary) override
Stamp the change reason on the in-flight instrument before the dialog calls saveInstrument.
Definition SwapInstrumentForm.cpp:435
void setReadOnly(bool readOnly) override
Toggle read-only on every editable widget.
Definition SwapInstrumentForm.cpp:416
void setClientManager(ClientManager *cm) override
Inject the NATS client used for load and save round-trips.
Definition SwapInstrumentForm.cpp:356
bool isDirty() const override
Has the user edited any field since the last load or save?
Definition SwapInstrumentForm.cpp:432
void clear() override
Reset the form to a blank state ready for create mode.
Definition SwapInstrumentForm.cpp:399
Form-local state for the swap instrument editor.
Definition SwapInstrumentForm.hpp:69