In this tutorial you'll value a portfolio straight from the Luminesce Query Editor, then turn the raw valuation into a readable report: one row per equity, with its name, its value and its share of the portfolio, sorted and totalled. It uses the example portfolio and recipe that come with every LUSID domain, so you can follow it step by step, and it shows how a single Luminesce query can combine data from more than one part of LUSID.
New to the Query Editor? Start with Getting started with the Luminesce Query Editor, which introduces the screen with a simpler query.
Prerequisites
Access to the Luminesce Query Editor in the LUSID web app, under Data Virtualisation > Query Editor. If you can't see the menu, your domain may need a Luminesce licence: contact technical support.
The example data in the
Finbourne-Examplesscope: theUK-Equitiesportfolio and theFinbourneExamplesRecipeMidThenBidrecipe.Permission to use the
Lusid.Portfolio.ValuationandLusid.Instrumentproviders.
Note: If you are the LUSID domain owner, you are automatically assigned the built-in
lusid-administratorrole, which has all the permissions you need. If you don't have a LUSID account yet, sign up for a free trial.
Step 1: Find the valuation provider
Sign in to the LUSID web app and select Data Virtualisation > Query Editor.
In the Catalogue on the right, type
Valuationin Search, then select Lusid.Portfolio.Valuation to see its fields.Hover over a few of them.
RecipeandEffectiveAtare parameters: they tell LUSID how to value the portfolio and on what date.MeasureNameandMeasureDecimalValueare columns: each row of the result is one measure, such as a holding's present value, with its value.
The Catalogue lists every provider you can use: LUSID's portfolios, holdings, transactions and instruments, Drive files, and providers that write data as well as read it. See How do I find providers and fields in the catalogue?
Step 2: Value the portfolio
Luminesce queries are written in the SQL dialect of SQLite, with a few extensions and limitations. Type or paste this query into the editor:
select v.*
from Lusid.Portfolio.Valuation v
where v.Recipe = 'Finbourne-Examples/FinbourneExamplesRecipeMidThenBid'
and v.PortfolioScope = 'Finbourne-Examples'
and v.PortfolioCode = 'UK-Equities'
and v.EffectiveAt = #2021-03-31#It values the UK-Equities example portfolio with the example recipe, at the end of the first quarter of 2021. Dates in Luminesce SQL go between # signs.
Select Run, or press Shift+Enter. Valuing a portfolio takes a little longer than reading a table, so you may see the query's progress while it runs. When the status shows Succeeded, the results appear under the editor.
By default, LUSID reports two measures for each holding, so each equity has two rows: Valuation/PV/Amount, its present value, in MeasureDecimalValue, and Valuation/PV/Ccy, the currency of that value, in MeasureStringValue. Each holding is identified only by its LusidInstrumentId, LUSID's own identifier for the instrument, which isn't easy to read. The next step fixes both.
Step 3: Make it a report
Change the query to this one:
select i.DisplayName as Equity,
v.MeasureDecimalValue as Value,
round(100.0 * v.MeasureDecimalValue / sum(v.MeasureDecimalValue) over (), 2) as PercentOfPortfolio,
v.LusidInstrumentId
from Lusid.Portfolio.Valuation v
inner join Lusid.Instrument i on i.LusidInstrumentId = v.LusidInstrumentId
where v.Recipe = 'Finbourne-Examples/FinbourneExamplesRecipeMidThenBid'
and v.PortfolioScope = 'Finbourne-Examples'
and v.PortfolioCode = 'UK-Equities'
and v.EffectiveAt = #2021-03-31#
and v.MeasureName = 'Valuation/PV/Amount'
order by Value descCompared with Step 2, it:
Keeps only the present value of each holding, with
MeasureName = 'Valuation/PV/Amount', so each equity has one row.Joins to the
Lusid.Instrumentprovider onLusidInstrumentId, to bring in each equity's name from a different part of LUSID.Works out each equity's share of the portfolio, with
sum(...) over (), which adds up the value of every row.Lists the most valuable equity first.
Run it. The first row is now the portfolio's largest holding, by name.
Step 4: Total and format the results
Add the portfolio's total value under the grid:
Open the Columns side bar on the right of the grid.
Drag Value into Aggregations (groups / footer).
On its pill, select the function and choose Sum.
The footer now shows the total value of the portfolio. Every holding in this portfolio is valued in the same currency, so their values can be added up; in a portfolio of several currencies, value it in one currency first.
Then make the numbers easier to read:
Open the Value column's menu and select Change Number Format. Choose 2 decimal places and Use 1000 separator (,).
Open the PercentOfPortfolio column's menu, select Conditional formatting, then Add rule. Choose is greater than, type
10, choose Cell fill and Green, and select Apply.
The holdings that make up more than a tenth of the portfolio now stand out. See How do I format results? and How do I filter, group and total results?
Step 5: Save and share the report
Select Save. Choose My Workspace, or a shared workspace to share the report with your team, and give it a Group and an Item Name, such as
UK-Equities valuation.Leave Save formattings ticked, so the total, number formats and colours are saved with it, and select Save.
To send the report to someone, select the export button above the grid, choose Excel, leave everything under Include ticked, and select Export. The workbook keeps the order, formats, colours and total.
See How do I save, open and share queries? and How do I copy and download results?
What's next
Change
#2021-03-31#to another date and run the report again, or add parameters so you're asked for the date and portfolio each time it runs. See How do I use parameters in a query?Report other measures, such as P&L or cost, with the
MeasuresToReturnparameter. See Lusid.Portfolio.Valuation and Lusid.Portfolio.Valuation.Measure.Run the report every morning, and save it to Drive. See How do I schedule a Luminesce SQL query?
See how each value was worked out. See How do I see where a value in my results came from?