ores.trading.trade_portfolio

Table of Contents

A portfolio a trade is reported in. A trade is filed in one book, and the book sits in one portfolio tree; a trade may also be reported in other portfolios, as ORE's Envelope/PortfolioIds states, each by the portfolio's name. The row resolves such a name to a portfolio of the trade's party, so a name that names no portfolio is refused rather than kept as text. The order is the source's order, and the ordinal preserves it.

The row is keyed by the trade and the ordinal, and references the trade anchor with a database foreign key. It copies the anchor's party, pinned to the anchor and to the portfolio, because row-level security needs the party on every row and a trade is reported only in its own party's portfolios. It replaces the envelope's portfolio id table.

1. Flags

2. Columns

2.1. trade_id

The trade reported in the portfolio.

ctx.generate_uuid()

2.2. trade_activity_id

The activity that wrote this version.

2.3. sequence_number

Ordinal of this portfolio among the trade's portfolios, from one.

1

2.4. portfolio_id

The portfolio the trade is reported in.

ctx.generate_uuid()

3. SQL

3.1. Flags

3.2. Checks

expression
"sequence_number" > 0

3.3. Indexes

name columns unique current_only where_extra
portfolio tenant_id, portfolio_id false true  

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. portfolio_id

The portfolio. Temporal, so a trigger check.

5. C++

5.1. Flags

5.2. Repository

5.3. Domain includes

#include <boost/uuid/uuid.hpp>

5.4. Conventions

5.5. Table display

column header
sequence_number Sequence
portfolio_id Portfolio
modified_by Modified By
version Version

6. See also

Emacs 29.3 (Org mode 9.6.15)