ores.trading.trade_party_role
Table of Contents
The role another party plays on a trade: calculation agent, executing broker and the like, one row per role. The firm's party and the counterparty the firm faces are not roles here: both are fixed for the trade's life and sit on the trade anchor, so a row naming the counterparty role is refused.
The row is keyed by the trade and references the anchor with a database foreign key. It copies the anchor's party, pinned to the anchor, because row-level security needs the party on every row.
1. Flags
2. Columns
2.1. trade_id
The trade this role belongs to.
ctx.generate_uuid()
2.2. trade_activity_id
The activity that wrote this version.
2.3. role
The role the other party plays (a party role type code).
std::string("CalculationAgent")
3. SQL
3.1. Flags
3.2. Checks
The counterparty the firm faces is on the anchor, not a role.
| expression |
|---|
| "role" <> 'Counterparty' |
3.3. Indexes
| name | columns | unique | current_only | where_extra |
4. Foreign keys
4.1. trade_id
A database foreign key: the anchor is immutable.
4.2. trade_activity_id
The activity that wrote this version. A database foreign key: the activity is immutable.
#include "ores.trading.api/generators/trade_activity_generator.hpp" #include "ores.trading.core/repository/trade_activity_repository.hpp"
{
auto activity = ores::trading::generators::generate_synthetic_trade_activity(ctx);
activity.party_id = *party_ctx.party_id();
ores::trading::repository::trade_activity_repository().write(party_ctx, activity);
v.trade_activity_id = activity.id;
}
4.3. role
The role catalogue is system reference data.
5. C++
5.1. Flags
5.2. Repository
5.3. Domain includes
#include <string> #include <boost/uuid/uuid.hpp>
5.4. Conventions
5.5. Table display
| column | header |
|---|---|
| trade_id | Trade ID |
| role | Role |
| modified_by | Modified By |
| version | Version |
5.6. Custom repository methods
5.7. Write observation
The trade's economic digest observes every write of this component. The observer's specialisation must be visible where the repository writes, so the repository includes it.
#include "ores.trading.core/repository/trade_write_observation.hpp"
6. See also
- ores.trading — component group overview.