Setting options on metrics

Prev Next

Some metrics let you fine-tune how LUSID calculates them by passing extra settings in the options field. With options, the same metric can report a P&L figure for a different window, a PV as at yesterday's close, or a portfolio total that leaves out holdings that failed to value. B

ecause each metric request carries its own options, you can put several versions of one metric side by side in a single valuation report.

Specifying options

Each metric in a valuation request has a key, an op and, optionally, an options object of name/value pairs. For example:

"metrics": [
  {"key": "Instrument/default/Name", "op": "Value"},
  {"key": "Valuation/PvInPortfolioCcy", "op": "Value"},                                                   # PV today
  {"key": "Valuation/PvInPortfolioCcy", "op": "Value", "options": {"DateTimeAgo": "P1BD"}},               # PV on the previous business day
  {"key": "ProfitAndLoss/Total/PortfolioCcy", "op": "Sum", "options": {"Window": "YTD"}},                 # P&L since the start of the year
  {"key": "Valuation/TotalPortfolioPvInPortfolioCcy", "op": "Value", "options": {"IgnoreErrors": true}}   # Continue if a holding fails to value
]

LUSID includes the options in the name of each result column, for example Valuation/PvInPortfolioCcy(DateTimeAgo="P1BD") or Sum(ProfitAndLoss/Total/PortfolioCcy(Window="YTD")). To use a shorter name, set the metric's returnAs field.

Finding out which options a metric supports

Call the GetAllQueryableKeys API. Each metric that takes options has an applicableOptions object, listing every option with its type, whether it's optional, its default and any allowed values. For example, the P&L metrics include:

"applicableOptions": {
  "Window": {
    "name": "Window",
    "type": "String",
    "description": "The Window for Profit and Loss calculations...",
    "optional": false,
    "allowedValueSet": ["YTD", "QTD", "MTD", "WTD", "Daily", "BusinessDaily", "Report"],
    "defaultValue": null
  },
  ...
}

Note the following:

  • Most metrics take no options. A metric with no applicableOptions object accepts no options.

  • If optional is false, you must supply the option. For example, every ProfitAndLoss metric requires a Window.

  • Option names are case-sensitive: Window works and window doesn't. Allowed values aren't: LUSID accepts ytd and reports it as YTD.

  • Options must have the right JSON type. For example, IgnoreErrors takes true, not "true".

  • If you pass an option the metric doesn't support, or an invalid value, LUSID rejects the whole valuation request. The error names the problem, for example The following options were extra: [DateTimeAgo] or Option "Window" was not provided, but is required.

  • You can only use metrics with options in metrics. You can't use them in groupBy, filters or sort.

Available options

Metrics

Option

What it does

Values

All ProfitAndLoss metrics. More information.

Window

Sets the start of the P&L period. Mandatory.

YTD, QTD, MTD, WTD, Daily, BusinessDaily, Report (the earliest date in the valuation schedule). Unrealised P&L metrics also accept Inception.

Type

Reports P&L as an amount or a percentage.

Amount (default) or Percentage

TimeZone

The time zone that decides when the window starts. Has no effect with Report or Inception.

An IANA time zone ID, for example Europe/London

StartDateOverrideUTC

Starts the P&L period at an exact time instead of using Window.

A UTC datetime before the valuation date

MovementName

Restricts P&L to movements with this name, as set on your transaction types. Accrual and amortisation have no movement name, so values for individual movements don't add up to the unrestricted total.

A movement name

PV, price, units and face metrics. More information.

DateTimeAgo

Calculates the metric at an earlier (or later) point in time.

A period or cron expression

Valuation/TotalPortfolio… and Valuation/TotalGroup… metrics. More information.

IgnoreErrors

Leaves holdings that failed to value out of the total.

false (default) or true

Valuation/PV, Valuation/PvInPortfolioCcy, Valuation/PvInReportCcy, Valuation/InstrumentPV and the Analytic metrics

ScenarioScope, ScenarioCode

Applies the market data shifts of a stored scenario to this column only. Supply both together.

The scenario's scope and code

PricingBasis

Prices this column off a different side of the instrument price quote. FX rates and curves are unchanged.

Mid, Bid or Ask

Aggregation/NetExposureWeight, Aggregation/GrossExposureWeight and their MSCI versions

Benchmark

Reports the weight for the equivalent holding in the portfolio's benchmark.

false (default) or true

RelatedPortfolio/Weight, and properties of related entities

RelationshipDefinitionIdScope, RelationshipDefinitionIdCode

Identifies the relationship to follow.

The relationship definition's scope and code

Pointwise Risk/Rates, Risk/Credit and Risk/Inflation delta and gamma metrics, and Risk/Rates/Krd

Buckets

Remaps the risk ladder onto your own tenors.

Two or more increasing tenors, for example 1Y,2Y,5Y,10Y. By default, the curve's own nodes.

Analytic/CS01, Analytic/CS01/Central, Analytic/SpreadDuration, Analytic/ISpread, Analytic/ZSpread

DiscountCurve

The curve to measure the spread over.

A market data key, for example Rates.EUR.EUR-6M, in the instrument's own currency. By default, its discounting curve.

Analytic/ModifiedDuration, Analytic/Convexity, Analytic/ZSpread

IgnoreOptionality

Calculates as if the instrument had no call or put schedule.

false (default) or true

Analytic/var metrics, Aggregation/VaR/Histogram

Confidence, HoldingPeriodDays and others

Configure value-at-risk calculations.

See the applicableOptions field when you retrieve metric details.

Risk/All/Base/Waterfall, Risk/All/Base/TransientWaterfall

Grouping, PriorDate

Set how the risk waterfall groups its steps and which date it explains from.

PerDependency (default) or FactorClass; an ISO date, by default the previous weekday

Risk/Model/Pfolio/FactorGroup, Risk/Model/Pfolio/ActiveFactorGroup

FactorGroup

The factor group to calculate risk for.

A factor group the model supports

Holding/SettlementSchedule

includeSettlementEventsAfterDays

How many days after the valuation date to include settlements for.

A whole number

Analytic/scr metrics

Solvency II options

Configure Solvency II capital calculations.

See the applicableOptions field when you retrieve metric details.

You can't always combine options from different rows on one metric. For example, DateTimeAgo with PricingBasis is rejected. To get both, request the metric twice.

Using DateTimeAgo to report a metric at another point in time

DateTimeAgo lets you report start-of-day, end-of-day or T-1 versions of a metric alongside today's value in a single request. LUSID fully revalues the portfolio at the time you choose. It uses the holdings and market data at that time, while keeping your request's asAt.

You can use DateTimeAgo with these metrics:

  • Valuation/PV, Valuation/PvInPortfolioCcy and Valuation/PvInReportCcy

  • Valuation/CleanPV, Valuation/CleanPvInPortfolioCcy and Valuation/CleanPvInReportCcy

  • Valuation/InstrumentPV, Valuation/InstrumentPvInPortfolioCcy and Valuation/InstrumentPvInReportCcy

  • Valuation/CleanPriceKey and Valuation/DirtyPriceKey, and their *InPortfolioCcy and *InReportCcy versions

  • Valuation/CurrentNotional and Valuation/Diagnostics/AssetBacked/PoolFactor

  • Holding/Units and Holding/CurrentFace

  • Quotes/Price

The value describes how far to move from the valuation date:

Value

For a valuation on Monday 13 January 2025 at 00:00 UTC…

P1D

The same time one day earlier: Sunday 12 January at 00:00. Use any ISO 8601 period, for example P7D or P1M.

P1BD

One business day earlier: Friday 10 January.

P1D|BD-

One day earlier, rolled back to a business day if that's a weekend or holiday: Friday 10 January. Use |BD+ to roll forward instead, or |BDM- and |BDM+ to roll without leaving the month.

P1D|CT17:00:00.000000[Europe/London]

One day back from the most recent 17:00 London cut before the valuation time: Saturday 11 January at 17:00. A time zone is required.

2025-01-06|CT00:00:00.000000[UTC]

An exact date and time: Monday 6 January at 00:00 UTC.

A0 0 * * 1

A cron expression: the most recent time that matches, here the most recent Monday at midnight.

-P1D

Prefix any value with - to look forward instead of back.

Note the following:

  • Business days come from the holidayCalendars in your valuation schedule. If you don't specify any, LUSID skips only weekends.

  • If a holding didn't exist at the earlier time, its column is empty. A holding that existed then but has since been sold gets its own row, containing the earlier value.

  • Operations such as Sum work as usual. For example, grouping by Valuation/EffectiveAt and requesting Sum of Valuation/PvInPortfolioCcy with and without "DateTimeAgo": "P1BD" gives you today's and yesterday's portfolio PV side by side.

  • If a holding fails to value at the earlier time, the whole request fails unless your recipe has the allowPartiallySuccessfulEvaluation recipe option set to allow partial success. In that case, only the affected cells are empty.

  • You can't request DateTimeAgo in the same valuation request as benchmark metrics or RelatedPortfolio/Weight.

Using IgnoreErrors to calculate a total when some holdings fail

By default, if any holding fails to value, the Valuation/TotalPortfolio* and Valuation/TotalGroup* total metrics are empty, and the error appears in Aggregation/Errors. Set IgnoreErrors to true to calculate the total from the holdings that did value instead:

{"key": "Valuation/TotalPortfolioPvInPortfolioCcy", "op": "Value", "options": {"IgnoreErrors": true}}

Note the following:

  • IgnoreErrors only has an effect if your recipe has the allowPartiallySuccessfulEvaluation recipe option set to allow partial success. Otherwise, a holding that fails to value fails the whole request.

  • Valuation/Weight and the Aggregation weight metrics always divide by the total without IgnoreErrors. If any holding fails, they're empty.