Every metric has a supportedOperations list that you can see when you call the GetAllQueryableKeys API. For example, Valuation/PV is defined as follows:
{
"addressKey": "Valuation/PV",
"description": "The present value of a holding of an instrument, at a point in time, in the settlement currency if applicable, otherwise domestic currency. Includes accrued interest",
"displayName": "PV",
"type": "Result0D",
"flattenedType": "Decimal",
"scalesWithHoldingQuantity": true,
"supportedOperations": "Sum,DefaultSum,Proportion,Average,Count,Min,Max,Value,Append,SumOfPositiveValues,SumOfNegativeValues,SumOfAbsoluteValues,ProportionOfAbsoluteValues,SumCumulativeInAdvance,SumCumulativeInArrears",
"lifeCycleStatus": "Experimental"
}When you request a metric in a valuation report, you pair its key with one operation in the op field. You can always request a metric's Value. Text, date and true/false metrics also support Count. Numeric metrics support the full set of operations below.
How operations work
Each operation is applied to a group of rows:
If you specify
groupByin the valuation request, each group is the set of holdings that share the same values for yourgroupBymetrics. LUSID returns one row per group.If you omit
groupBy, LUSID returns one row per holding. The whole report is treated as a single group: operations such asSumcalculate a grand total and repeat it on every row.If your valuation schedule spans several dates, the whole report covers every date. For example, with no
groupBy,Sumadds up values across all the dates. To get one total per date, group byValuation/EffectiveAt.Proportion operations always divide by the total for the whole report, not by the total for the row's own group.
Filters are applied first. Operations only see the rows that pass any
filtersyou specify in your valuation request.
Available operations
The examples come from a GBP portfolio holding five positions, valued without groupBy. In portfolio currency (Valuation/PvInPortfolioCcy), their values are 1000, 800, -200 (a short position), 1000 and 400, so the total is 3000.
Operation | What LUSID calculates | Example result for the 800 row |
|---|---|---|
| The metric's value for the row. In a grouped row, LUSID only returns a value if it's the same for every holding in the group. Otherwise the cell is empty. | 800 |
| The total of all values in the group. | 3000 |
| Behaves like | 800 |
| The total divided by the number of values in the group. | 600 |
| The number of values in the group. | 5 |
| The smallest value in the group. | -200 |
| The largest value in the group. | 1000 |
| The total of the positive values only (for example, long positions). | 3200 |
| The total of the negative values only (for example, short positions). | -200 |
| The total ignoring signs, so that long and short positions both add. This is useful for gross exposure. | 3400 |
| The group's total divided by the total for the whole report. Results across the report add up to 1. | 0.267 (800 ÷ 3000) |
| The group's total ignoring signs, divided by the whole report's total ignoring signs. | 0.235 (800 ÷ 3400) |
| A running total down the grouped rows, including the current row. Only meaningful with | — |
| A running total down the grouped rows, excluding the current row. It's empty for the first row. Only meaningful with | — |
LUSID names each result column after the operation and metric, for example Sum(Valuation/PvInPortfolioCcy). The exception is Value, which uses the metric key on its own.
Summing values in different currencies
LUSID cannot sum amounts in different currencies. If you request Sum, Average, Min or Max for a metric such as Valuation/PV and a group contains both GBP and USD amounts, LUSID leaves the cell empty. It also adds a message to the row's Aggregation/Errors metric, for example:
metadata mismatch Dim:0,Units:(USD) != Dim:0,Units:(GBP).To total amounts across currencies, use a version of the metric that LUSID converts to a single currency:
…InPortfolioCcymetrics, such asValuation/PvInPortfolioCcyandValuation/ExposureInPortfolioCcy, are safe to total within one portfolio. They're also safe across portfolios that share a base currency.…InReportCcymetrics, such asValuation/PvInReportCcy, are always safe to total, including across portfolios with different base currencies. To use them, setreportCurrencyin your valuation request.
Note: LUSID only checks currencies. Plain numbers have no unit, so LUSID adds them without warning. For example,
SumofHolding/default/Unitsacross a whole portfolio returns a number that mixes shares of different equities with units of cash. Only sum units when you've grouped by instrument.
Calculating totals, proportions and weights
There are three ways to report portfolio totals, and the percentage each holding contributes, in a valuation report:
Operations (
Sum,Proportionand so on): flexible, and they follow your grouping and filters.Total metrics (
Valuation/TotalPortfolio…andValuation/TotalGroup…): one whole-portfolio or whole-group total on every row, unaffected by filters.Weight metrics (
Valuation/Weightand theAggregation/…Weightmetrics): a holding's or group's exposure as a share of the whole portfolio.
Which approach to use
You want… | Use | Example metrics |
|---|---|---|
A total for the portfolio, or for each group in your report | The |
|
Each holding's or group's share of the report total | The |
|
The whole-portfolio total alongside every holding row, even if you filter the report | A total metric with |
|
The total for a portfolio group alongside every row | A group total metric with |
|
Each holding's net exposure as a share of total portfolio PV |
|
|
Net or gross exposure weights for each group |
|
|
Total metrics
LUSID calculates each total metric from every holding in the portfolio before it applies your filters or groupBy. It then reports the same figure on every row for that portfolio and date. This makes the total useful for showing the whole portfolio's value next to a filtered selection of holdings, or as the denominator in a derived property.
Metric | Total of | Over |
|---|---|---|
|
| Each portfolio |
|
| Each portfolio |
|
| Each portfolio |
|
| Each portfolio |
|
| Each portfolio |
|
| Each portfolio |
|
| The portfolio group you're valuing |
|
| The portfolio group you're valuing |
|
| The portfolio group you're valuing |
|
| The portfolio group you're valuing |
|
| The portfolio group you're valuing |
|
| The portfolio group you're valuing |
Note the following:
Request total metrics with
Value. Because every row already carries the full total,Summultiplies it by the number of rows. For example, in a group of three holdings,Sumof a 3000 total returns 9000."Group" means a portfolio group, not a
groupBygroup.TotalGroup…metrics are only populated when you value a portfolio group. If you value single portfolios, they're empty.For group totals in portfolio currency, every portfolio in the group must share a base currency. Otherwise the cell is empty and
Aggregation/ErrorsreportsMixed currencies in total. If base currencies differ, use the…InReportCcymetric and setreportCurrency.…InReportCcymetrics need a report currency. If you don't setreportCurrency, they come back empty.One failure empties the total. If any holding fails to value, the total is empty. To leave failed holdings out of the total instead, set the
IgnoreErrorsoption totrue, for example{"key": "Valuation/TotalPortfolioPvInPortfolioCcy", "op": "Value", "options": {"IgnoreErrors": true}}.
For example, valuing a GBP portfolio worth 3000 with a filter that keeps only its GBP holdings returns:
Holding |
|
|
|
|---|---|---|---|
UK equity | 1000 | 0.556 | 3000 |
UK equity (short) | -200 | -0.111 | 3000 |
GBP cash | 1000 | 0.556 | 3000 |
Proportion measures each holding against the 1800 that passed the filter. The total metric still reports the whole portfolio.
Weight metrics
Valuation/Weight reports each holding's exposure in portfolio currency divided by the total PV of the whole portfolio. For a reference portfolio, it's the holding's units divided by the portfolio's total units.
The Aggregation weight metrics apply the same calculation to each row of your report. If you group your report, they add up each group first:
Metric | What LUSID calculates for each row or group |
|---|---|
| Sum of |
| Sum of absolute |
| As |
| As |
Note the following:
Request these metrics with
Value. LUSID calculates them for each group itself.Matching operations.
Aggregation/NetExposureWeightgives the same result asSumofValuation/Weight, andAggregation/GrossExposureWeightasSumOfAbsoluteValuesofValuation/Weight.The
Benchmarkoption. Set it totrueto calculate the weight using the portfolio's benchmark instead.
Other Aggregation metrics
Metric | Notes |
|---|---|
| Lists any errors for the row, such as a holding that failed to value or a currency mismatch. LUSID adds it to any row with errors, even if you don't request it. |
| Older versions of the weight metrics. They divide by the total |
| For duration, we recommend the |
| Experimental. For value at risk, we recommend the |