ores.refdata.portfolio
Table of Contents
Represents organizational, risk, or reporting groupings. Never holds trades directly. Supports hierarchical structure via self-referencing parent_portfolio_id.
1. Flags
:seed_currency:: the eventing integration fixtures write a synthetic
portfolio whose aggregation currency the generator hardcodes as the
synthetic currency generator's first code (X-0); the portfolios insert
trigger validates aggregation_ccy against the active currencies for
the write tenant — the fixtures must seed that currency row. The flag
also drives the FK-parent seed block: a child whose
parent_portfolio_id FK points here seeds that currency before writing
the parent row.
2. Columns
2.1. id
UUID uniquely identifying this portfolio.
Surrogate key for the portfolio record.
2.2. party_id
Party that owns this portfolio.
Set server-side from the authenticated session. Enforced by RLS.
ctx.generate_uuid()
2.3. name
Human-readable name for the portfolio.
e.g., 'Global Rates', 'APAC Credit'.
std::string(faker::company::companyName()) + " Portfolio"
2.4. description
Optional free-text description of the portfolio.
std::string(faker::lorem::sentence())
2.5. parent_portfolio_id
Self-referencing FK. NULL indicates a root node.
Links to the parent portfolio in the hierarchy.
std::nullopt
2.6. owner_unit_id
Business unit responsible for management.
References the business_units table.
// Left null: optional FK, and the insert trigger rejects ids that do // not name an active business unit. std::nullopt
2.7. purpose_type
Portfolio purpose classification.
References purpose_types lookup (Risk, Regulatory, ClientReporting, Internal). Defaults to
Risk so a freshly-constructed portfolio (the Add dialog, before the
Purpose Type combo's async populate completes) always carries a value the
FK-validation trigger accepts.
std::string("Risk")
2.8. aggregation_ccy
Currency for P&L/risk aggregation at this node.
ISO 4217 currency code.
// X-0 is the sentinel code the eventing integration fixtures seed // before writing this row, directly or through a child's FK-parent // seed: the aggregation-currency trigger accepts only codes of active // currencies for the write tenant, so no fixed code is valid on its own // and the seed must come first. A caller that does not seed it must // overwrite this with a code it has written, or the insert is rejected. std::string("X-0")
2.9. is_virtual
If true, node is purely for on-demand reporting.
Not persisted in trade attribution when virtual.
false
2.10. status
Current lifecycle status (Active, Inactive, Closed). No dedicated
lookup table exists yet (unlike book_status) – a fixed three-value
list, defaulting to Active for the same reason as
purpose_type=/book's =book_status: a freshly-constructed portfolio
always carries a value.
std::string("Active")
3. Artefact columns
The import carries is_virtual as 0 or 1, which ores_refdata_publish_portfolios_from_dq_fn converts to the store's boolean with (m.is_virtual ! 0)=. The Acme populate writes those literals, so the staging column stays integer.
3.1. id
3.2. version
3.3. name
3.4. parent_portfolio_id
3.5. owner_unit_id
3.6. purpose_type
3.7. aggregation_ccy
3.8. is_virtual
4. SQL
4.1. Flags
5. Foreign keys
5.1. aggregation_ccy
5.2. party_id
5.3. parent_portfolio_id
Self-referencing: a portfolio's own writes recursively bump its parent portfolio's version too (multi-level composite-entity versioning), so that a nested tree's top-level "as of version N" composition sees every descendant's state as of that same instant – not just its immediate children. NULL (root node) safely no-ops: the touch function's row lookup finds nothing for a NULL id and returns without effect, terminating the recursion. See the "Temporal composite entity versioning" architecture doc, "Multi-level composition".
5.4. owner_unit_id
6. Insert trigger
6.1. Validations
| column | validation_function |
|---|---|
| purpose_type | ores_refdata_validate_purpose_type_fn |
| aggregation_ccy | ores_refdata_validate_currency_fn |
7. C++
7.1. Flags
7.2. Repository
7.3. Domain includes
#include <chrono> #include <optional> #include <string> #include <boost/uuid/uuid.hpp>
7.4. Entity includes
#include <string> #include "sqlgen/Timestamp.hpp" #include "sqlgen/PrimaryKey.hpp"
7.5. Conventions
7.6. Table display
| column | header |
|---|---|
| name | Name |
| purpose_type | Purpose |
| aggregation_ccy | Currency |
| is_virtual | Virtual |
| modified_by | Modified By |
| version | Version |
7.7. Presentation
7.7.1. Detail fields
parent_portfolio_id=/=owner_unit_id (optional UUID FKs) are not
exposed here, matching book's owner_unit_id precedent – neither
codegen entity has an entity-picker combo widget yet.
| field | label | widget | type | is_key | is_required | placeholder | flag_source | combo_allow_blank | combo_fetch | combo_domain_type | combo_fetch_include | combo_fetch_fn | combo_watcher_name | combo_code_field | combo_tooltip_field | combo_sort_field | combo_label | combo_setter_pascal | combo_values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | Id | idEdit | line_edit | true | true | Portfolio id | |||||||||||||
| name | Name | nameEdit | line_edit | true | Enter portfolio name | ||||||||||||||
| purpose_type | Purpose Type | purposeTypeCombo | dynamic_combo | refdata::domain::purpose_type | fetch_purpose_types | purposeTypeWatcher | code | description | display_order | purpose types | PurposeTypeCombo | ||||||||
| status | Status | statusCombo | static_combo | Active,Inactive,Closed,Frozen,Pending | |||||||||||||||
| is_virtual | Virtual | isVirtualCheckBox | check_box | ||||||||||||||||
| aggregation_ccy | Aggregation Currency | aggregationCcyEdit | flagged_combo | currency | |||||||||||||||
| description | Description | descriptionEdit | text_edit | Enter description (optional) |
7.7.2. Columns
| enum_name | field | header | type | width | is_badge | badge_key |
|---|---|---|---|---|---|---|
| Name | name | Name | string | 250 | ||
| PurposeType | purpose_type | Purpose | string | 120 | ||
| Status | status | Status | string | 100 | true | portfolio_status |
| AggregationCcy | aggregation_ccy | Agg. Currency | string | 120 | ||
| IsVirtual | is_virtual | Virtual | bool | 70 | true | is_virtual |
| Version | version | Version | int | 80 | ||
| ModifiedBy | modified_by | Modified By | string | 120 | ||
| RecordedAt | recorded_at | Recorded At | timestamp | 150 |
7.7.3. Icon columns
| column | accessor | field1 | field2 |
|---|---|---|---|
| AggregationCcy | currency_flag_icon | aggregation_ccy |
7.8. Custom repository methods
8. See also
- ores.refdata — component group overview.