ores.trading.equity_position_instrument
Table of Contents
Represents EquityPosition and EquityOptionPosition trades: a plain
equity holding or an equity option position. For option positions,
option_data_json holds the serialised option parameters; for plain
equity positions, price captures the reference price and
option_data_json is null.
Flags
Natural keys
Columns
instrument_id
UUID uniquely identifying this equity position instrument.
Surrogate key for the instrument record.
trade_type_code
Trade type code (soft FK to ores_trading_trade_types_tbl).
Routes ORE product types: EquityPosition, EquityOptionPosition.
std::string("EquityPosition")
party_id
Party that owns this instrument.
Set from session variable app.current_party_id.
trade_id
Optional soft FK to the parent trade.
Links instrument to a trade if applicable.
underlying_name
Name of the underlying equity.
std::string("ACME Corp")
currency
ISO 4217 currency code.
e.g., USD, EUR, GBP.
std::string("USD")
quantity
Number of shares / contracts held.
100.0
price
Entry price; absent for market-price positions.
option_data_json
EquityOptionPosition only: serialised option parameters; empty otherwise.
description
Optional free-text description.
Human-readable notes about this instrument.
SQL
Flags
Checks
| expression |
|---|
| "underlying_name" <> '' |
| "currency" <> '' |
| "trade_type_code" in ('EquityPosition', 'EquityOptionPosition') |
| ("trade_type_code" = 'EquityOptionPosition' and "option_data_json" is not null) or ("trade_type_code" = 'EquityPosition' and "option_data_json" is null) |
Indexes
| name | columns | unique | current_only | where_extra |
|---|---|---|---|---|
| party | tenant_id, party_id | false | true | |
| trade_id | tenant_id, trade_id | true | true | trade_id is not null |
| trade_type | tenant_id, trade_type_code | false | true |
Insert trigger
Validations
| column | validation_function |
|---|---|
| trade_type_code | ores_trading_validate_trade_type_fn |
C++
The C++ domain class is decomposed into nested sub-structs (the C1202
pattern from PRs #1047/#1071/#1075/#1083/#1085): the implicit scaffolding
columns (version, tenant_id, workspace_id, the primary key) and the
columns marked :group: identity above fold into an
instrument_identity identity; member (see the
ores.trading.instrument_identity field-group model), the implicit audit
columns fold into an ores::dq::domain::audit_record audit; member (see
the ores.dq.audit_record field-group model), and the remaining columns
stay flat in between. The SQL schema, DB entity and column lists are
unaffected — only the domain class and the mapper's domain-side accesses
nest. The entity templates consume these annotations; domain and
repository profiles regenerate correctly.
Flags
Repository
Domain includes
#include <optional> #include <string>
Conventions
Custom repository methods
See also
- ores.trading — component group overview.