ORE Studio 0.0.4
Loading...
Searching...
No Matches
instrument_protocol.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_TRADING_MESSAGING_INSTRUMENT_PROTOCOL_HPP
21#define ORES_TRADING_MESSAGING_INSTRUMENT_PROTOCOL_HPP
22
23#include <string>
24#include <vector>
25#include "ores.trading.api/domain/instrument.hpp"
26#include "ores.trading.api/domain/swap_leg.hpp"
27#include "ores.trading.api/domain/fx_instrument.hpp"
28#include "ores.trading.api/domain/bond_instrument.hpp"
29#include "ores.trading.api/domain/credit_instrument.hpp"
30#include "ores.trading.api/domain/equity_instrument.hpp"
31#include "ores.trading.api/domain/commodity_instrument.hpp"
32#include "ores.trading.api/domain/composite_instrument.hpp"
33#include "ores.trading.api/domain/composite_leg.hpp"
34#include "ores.trading.api/domain/scripted_instrument.hpp"
35
36namespace ores::trading::messaging {
37
38struct get_instruments_request {
39 using response_type = struct get_instruments_response;
40 static constexpr std::string_view nats_subject = "trading.v1.instruments.list";
41 int offset = 0;
42 int limit = 100;
43};
44
45struct get_instruments_response {
46 std::vector<ores::trading::domain::instrument> instruments;
47 int total_available_count = 0;
48 bool success = true;
49 std::string message;
50};
51
52struct save_instrument_request {
53 using response_type = struct save_instrument_response;
54 static constexpr std::string_view nats_subject = "trading.v1.instruments.save";
56 std::vector<ores::trading::domain::swap_leg> legs;
57};
58
59struct save_instrument_response {
60 bool success = false;
61 std::string message;
62};
63
64struct delete_instrument_request {
65 using response_type = struct delete_instrument_response;
66 static constexpr std::string_view nats_subject = "trading.v1.instruments.delete";
67 std::vector<std::string> ids;
68};
69
70struct delete_instrument_response {
71 bool success = false;
72 std::string message;
73};
74
75struct get_instrument_history_request {
76 using response_type = struct get_instrument_history_response;
77 static constexpr std::string_view nats_subject = "trading.v1.instruments.history";
78 std::string id;
79};
80
81struct get_instrument_history_response {
82 bool success = false;
83 std::string message;
84 std::vector<ores::trading::domain::instrument> history;
85};
86
87struct get_swap_legs_request {
88 using response_type = struct get_swap_legs_response;
89 static constexpr std::string_view nats_subject = "trading.v1.instruments.legs.list";
90 std::string instrument_id;
91};
92
93struct get_swap_legs_response {
94 std::vector<ores::trading::domain::swap_leg> legs;
95 bool success = true;
96 std::string message;
97};
98
99// ---- FX instrument protocol ----
100
101struct get_fx_instruments_request {
102 using response_type = struct get_fx_instruments_response;
103 static constexpr std::string_view nats_subject =
104 "trading.v1.fx_instruments.list";
105 int offset = 0;
106 int limit = 100;
107};
108
109struct get_fx_instruments_response {
110 std::vector<ores::trading::domain::fx_instrument> instruments;
111 int total_available_count = 0;
112 bool success = true;
113 std::string message;
114};
115
116struct save_fx_instrument_request {
117 using response_type = struct save_fx_instrument_response;
118 static constexpr std::string_view nats_subject =
119 "trading.v1.fx_instruments.save";
121};
122
123struct save_fx_instrument_response {
124 bool success = false;
125 std::string message;
126};
127
128struct delete_fx_instrument_request {
129 using response_type = struct delete_fx_instrument_response;
130 static constexpr std::string_view nats_subject =
131 "trading.v1.fx_instruments.delete";
132 std::vector<std::string> ids;
133};
134
135struct delete_fx_instrument_response {
136 bool success = false;
137 std::string message;
138 std::vector<std::pair<std::string, std::pair<bool, std::string>>> results;
139};
140
141struct get_fx_instrument_history_request {
142 using response_type = struct get_fx_instrument_history_response;
143 static constexpr std::string_view nats_subject =
144 "trading.v1.fx_instruments.history";
145 std::string id;
146};
147
148struct get_fx_instrument_history_response {
149 bool success = false;
150 std::string message;
151 std::vector<ores::trading::domain::fx_instrument> history;
152};
153
154// ---- Bond instrument protocol ----
155
156struct get_bond_instruments_request {
157 using response_type = struct get_bond_instruments_response;
158 static constexpr std::string_view nats_subject =
159 "trading.v1.bond_instruments.list";
160 int offset = 0;
161 int limit = 100;
162};
163
164struct get_bond_instruments_response {
165 std::vector<ores::trading::domain::bond_instrument> instruments;
166 int total_available_count = 0;
167 bool success = true;
168 std::string message;
169};
170
171struct save_bond_instrument_request {
172 using response_type = struct save_bond_instrument_response;
173 static constexpr std::string_view nats_subject =
174 "trading.v1.bond_instruments.save";
176};
177
178struct save_bond_instrument_response {
179 bool success = false;
180 std::string message;
181};
182
183struct delete_bond_instrument_request {
184 using response_type = struct delete_bond_instrument_response;
185 static constexpr std::string_view nats_subject =
186 "trading.v1.bond_instruments.delete";
187 std::vector<std::string> ids;
188};
189
190struct delete_bond_instrument_response {
191 bool success = false;
192 std::string message;
193 std::vector<std::pair<std::string, std::pair<bool, std::string>>> results;
194};
195
196struct get_bond_instrument_history_request {
197 using response_type = struct get_bond_instrument_history_response;
198 static constexpr std::string_view nats_subject =
199 "trading.v1.bond_instruments.history";
200 std::string id;
201};
202
203struct get_bond_instrument_history_response {
204 bool success = false;
205 std::string message;
206 std::vector<ores::trading::domain::bond_instrument> history;
207};
208
209// ---- Credit instrument protocol ----
210
211struct get_credit_instruments_request {
212 using response_type = struct get_credit_instruments_response;
213 static constexpr std::string_view nats_subject =
214 "trading.v1.credit_instruments.list";
215 int offset = 0;
216 int limit = 100;
217};
218
219struct get_credit_instruments_response {
220 std::vector<ores::trading::domain::credit_instrument> instruments;
221 int total_available_count = 0;
222 bool success = true;
223 std::string message;
224};
225
226struct save_credit_instrument_request {
227 using response_type = struct save_credit_instrument_response;
228 static constexpr std::string_view nats_subject =
229 "trading.v1.credit_instruments.save";
231};
232
233struct save_credit_instrument_response {
234 bool success = false;
235 std::string message;
236};
237
238struct delete_credit_instrument_request {
239 using response_type = struct delete_credit_instrument_response;
240 static constexpr std::string_view nats_subject =
241 "trading.v1.credit_instruments.delete";
242 std::vector<std::string> ids;
243};
244
245struct delete_credit_instrument_response {
246 bool success = false;
247 std::string message;
248 std::vector<std::pair<std::string, std::pair<bool, std::string>>> results;
249};
250
251struct get_credit_instrument_history_request {
252 using response_type = struct get_credit_instrument_history_response;
253 static constexpr std::string_view nats_subject =
254 "trading.v1.credit_instruments.history";
255 std::string id;
256};
257
258struct get_credit_instrument_history_response {
259 bool success = false;
260 std::string message;
261 std::vector<ores::trading::domain::credit_instrument> history;
262};
263
264// ---- Equity instrument protocol ----
265
266struct get_equity_instruments_request {
267 using response_type = struct get_equity_instruments_response;
268 static constexpr std::string_view nats_subject =
269 "trading.v1.equity_instruments.list";
270 int offset = 0;
271 int limit = 100;
272};
273
274struct get_equity_instruments_response {
275 std::vector<ores::trading::domain::equity_instrument> instruments;
276 int total_available_count = 0;
277 bool success = true;
278 std::string message;
279};
280
281struct save_equity_instrument_request {
282 using response_type = struct save_equity_instrument_response;
283 static constexpr std::string_view nats_subject =
284 "trading.v1.equity_instruments.save";
286};
287
288struct save_equity_instrument_response {
289 bool success = false;
290 std::string message;
291};
292
293struct delete_equity_instrument_request {
294 using response_type = struct delete_equity_instrument_response;
295 static constexpr std::string_view nats_subject =
296 "trading.v1.equity_instruments.delete";
297 std::vector<std::string> ids;
298};
299
300struct delete_equity_instrument_response {
301 bool success = false;
302 std::string message;
303 std::vector<std::pair<std::string, std::pair<bool, std::string>>> results;
304};
305
306struct get_equity_instrument_history_request {
307 using response_type = struct get_equity_instrument_history_response;
308 static constexpr std::string_view nats_subject =
309 "trading.v1.equity_instruments.history";
310 std::string id;
311};
312
313struct get_equity_instrument_history_response {
314 bool success = false;
315 std::string message;
316 std::vector<ores::trading::domain::equity_instrument> history;
317};
318
319// ---- Commodity instrument protocol ----
320
321struct get_commodity_instruments_request {
322 using response_type = struct get_commodity_instruments_response;
323 static constexpr std::string_view nats_subject =
324 "trading.v1.commodity_instruments.list";
325 int offset = 0;
326 int limit = 100;
327};
328
329struct get_commodity_instruments_response {
330 std::vector<ores::trading::domain::commodity_instrument> instruments;
331 int total_available_count = 0;
332 bool success = true;
333 std::string message;
334};
335
336struct save_commodity_instrument_request {
337 using response_type = struct save_commodity_instrument_response;
338 static constexpr std::string_view nats_subject =
339 "trading.v1.commodity_instruments.save";
341};
342
343struct save_commodity_instrument_response {
344 bool success = false;
345 std::string message;
346};
347
348struct delete_commodity_instrument_request {
349 using response_type = struct delete_commodity_instrument_response;
350 static constexpr std::string_view nats_subject =
351 "trading.v1.commodity_instruments.delete";
352 std::vector<std::string> ids;
353};
354
355struct delete_commodity_instrument_response {
356 bool success = false;
357 std::string message;
358 std::vector<std::pair<std::string, std::pair<bool, std::string>>> results;
359};
360
361struct get_commodity_instrument_history_request {
362 using response_type = struct get_commodity_instrument_history_response;
363 static constexpr std::string_view nats_subject =
364 "trading.v1.commodity_instruments.history";
365 std::string id;
366};
367
368struct get_commodity_instrument_history_response {
369 bool success = false;
370 std::string message;
371 std::vector<ores::trading::domain::commodity_instrument> history;
372};
373
374// ---- Composite instrument protocol ----
375
376struct get_composite_instrument_legs_request {
377 using response_type = struct get_composite_instrument_legs_response;
378 static constexpr std::string_view nats_subject =
379 "trading.v1.composite_instruments.legs.list";
380 std::string instrument_id;
381};
382
383struct get_composite_instrument_legs_response {
384 std::vector<ores::trading::domain::composite_leg> legs;
385 bool success = true;
386 std::string message;
387};
388
389struct get_composite_instruments_request {
390 using response_type = struct get_composite_instruments_response;
391 static constexpr std::string_view nats_subject =
392 "trading.v1.composite_instruments.list";
393 int offset = 0;
394 int limit = 100;
395};
396
397struct get_composite_instruments_response {
398 std::vector<ores::trading::domain::composite_instrument> instruments;
399 int total_available_count = 0;
400 bool success = true;
401 std::string message;
402};
403
404struct save_composite_instrument_request {
405 using response_type = struct save_composite_instrument_response;
406 static constexpr std::string_view nats_subject =
407 "trading.v1.composite_instruments.save";
409 std::vector<ores::trading::domain::composite_leg> legs;
410};
411
412struct save_composite_instrument_response {
413 bool success = false;
414 std::string message;
415};
416
417struct delete_composite_instrument_request {
418 using response_type = struct delete_composite_instrument_response;
419 static constexpr std::string_view nats_subject =
420 "trading.v1.composite_instruments.delete";
421 std::vector<std::string> ids;
422};
423
424struct delete_composite_instrument_response {
425 bool success = false;
426 std::string message;
427 std::vector<std::pair<std::string, std::pair<bool, std::string>>> results;
428};
429
430struct get_composite_instrument_history_request {
431 using response_type = struct get_composite_instrument_history_response;
432 static constexpr std::string_view nats_subject =
433 "trading.v1.composite_instruments.history";
434 std::string id;
435};
436
437struct get_composite_instrument_history_response {
438 bool success = false;
439 std::string message;
440 std::vector<ores::trading::domain::composite_instrument> history;
441};
442
443// ---- Scripted instrument protocol ----
444
445struct get_scripted_instruments_request {
446 using response_type = struct get_scripted_instruments_response;
447 static constexpr std::string_view nats_subject =
448 "trading.v1.scripted_instruments.list";
449 int offset = 0;
450 int limit = 100;
451};
452
453struct get_scripted_instruments_response {
454 std::vector<ores::trading::domain::scripted_instrument> instruments;
455 int total_available_count = 0;
456 bool success = true;
457 std::string message;
458};
459
460struct save_scripted_instrument_request {
461 using response_type = struct save_scripted_instrument_response;
462 static constexpr std::string_view nats_subject =
463 "trading.v1.scripted_instruments.save";
465};
466
467struct save_scripted_instrument_response {
468 bool success = false;
469 std::string message;
470};
471
472struct delete_scripted_instrument_request {
473 using response_type = struct delete_scripted_instrument_response;
474 static constexpr std::string_view nats_subject =
475 "trading.v1.scripted_instruments.delete";
476 std::vector<std::string> ids;
477};
478
479struct delete_scripted_instrument_response {
480 bool success = false;
481 std::string message;
482 std::vector<std::pair<std::string, std::pair<bool, std::string>>> results;
483};
484
485struct get_scripted_instrument_history_request {
486 using response_type = struct get_scripted_instrument_history_response;
487 static constexpr std::string_view nats_subject =
488 "trading.v1.scripted_instruments.history";
489 std::string id;
490};
491
492struct get_scripted_instrument_history_response {
493 bool success = false;
494 std::string message;
495 std::vector<ores::trading::domain::scripted_instrument> history;
496};
497
498}
499
500#endif
Bond instrument economics for Bond, ForwardBond, CallableBond, ConvertibleBond, and BondRepo trades.
Definition bond_instrument.hpp:38
Commodity instrument economics for all commodity ORE product types.
Definition commodity_instrument.hpp:48
Composite instrument economics for CompositeTrade and MultiLegOption ORE product types.
Definition composite_instrument.hpp:37
Credit instrument economics for CreditDefaultSwap, CDSIndex, SyntheticCDO, CreditDefaultSwapOption,...
Definition credit_instrument.hpp:39
Equity instrument economics for all equity ORE product types.
Definition equity_instrument.hpp:45
FX instrument economics for FxForward, FxSwap, and FxOption trades.
Definition fx_instrument.hpp:36
Parent instrument record holding economic terms for a trade.
Definition instrument.hpp:40
Scripted instrument economics for ORE AMC script-based product types.
Definition scripted_instrument.hpp:38