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
applicableOptionsobject accepts no options.If
optionalisfalse, you must supply the option. For example, everyProfitAndLossmetric requires aWindow.Option names are case-sensitive:
Windowworks andwindowdoesn't. Allowed values aren't: LUSID acceptsytdand reports it asYTD.Options must have the right JSON type. For example,
IgnoreErrorstakestrue, 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]orOption "Window" was not provided, but is required.You can only use metrics with options in
metrics. You can't use them ingroupBy,filtersorsort.
Available options
Metrics | Option | What it does | Values |
|---|---|---|---|
All |
| Sets the start of the P&L period. Mandatory. |
|
| Reports P&L as an amount or a percentage. |
| |
| The time zone that decides when the window starts. Has no effect with | An IANA time zone ID, for example | |
| Starts the P&L period at an exact time instead of using | A UTC datetime before the valuation date | |
| 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. |
| Calculates the metric at an earlier (or later) point in time. | A period or cron expression |
|
| Leaves holdings that failed to value out of the total. |
|
|
| Applies the market data shifts of a stored scenario to this column only. Supply both together. | The scenario's scope and code |
| Prices this column off a different side of the instrument price quote. FX rates and curves are unchanged. |
| |
|
| Reports the weight for the equivalent holding in the portfolio's benchmark. |
|
|
| Identifies the relationship to follow. | The relationship definition's scope and code |
Pointwise |
| Remaps the risk ladder onto your own tenors. | Two or more increasing tenors, for example |
|
| The curve to measure the spread over. | A market data key, for example |
|
| Calculates as if the instrument had no call or put schedule. |
|
|
| Configure value-at-risk calculations. | See the |
|
| Set how the risk waterfall groups its steps and which date it explains from. |
|
|
| The factor group to calculate risk for. | A factor group the model supports |
|
| How many days after the valuation date to include settlements for. | A whole number |
| Solvency II options | Configure Solvency II capital calculations. | See the |
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/PvInPortfolioCcyandValuation/PvInReportCcyValuation/CleanPV,Valuation/CleanPvInPortfolioCcyandValuation/CleanPvInReportCcyValuation/InstrumentPV,Valuation/InstrumentPvInPortfolioCcyandValuation/InstrumentPvInReportCcyValuation/CleanPriceKeyandValuation/DirtyPriceKey, and their*InPortfolioCcyand*InReportCcyversionsValuation/CurrentNotionalandValuation/Diagnostics/AssetBacked/PoolFactorHolding/UnitsandHolding/CurrentFaceQuotes/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… |
|---|---|
| The same time one day earlier: Sunday 12 January at 00:00. Use any ISO 8601 period, for example |
| One business day earlier: Friday 10 January. |
| One day earlier, rolled back to a business day if that's a weekend or holiday: Friday 10 January. Use |
| 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. |
| An exact date and time: Monday 6 January at 00:00 UTC. |
| A cron expression: the most recent time that matches, here the most recent Monday at midnight. |
| Prefix any value with |
Note the following:
Business days come from the
holidayCalendarsin 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
Sumwork as usual. For example, grouping byValuation/EffectiveAtand requestingSumofValuation/PvInPortfolioCcywith 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
allowPartiallySuccessfulEvaluationrecipe option set to allow partial success. In that case, only the affected cells are empty.You can't request
DateTimeAgoin the same valuation request as benchmark metrics orRelatedPortfolio/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:
IgnoreErrorsonly has an effect if your recipe has theallowPartiallySuccessfulEvaluationrecipe option set to allow partial success. Otherwise, a holding that fails to value fails the whole request.Valuation/Weightand theAggregationweight metrics always divide by the total withoutIgnoreErrors. If any holding fails, they're empty.