--- title: "Lusid.Portfolio.Return" slug: "lusidportfolioreturn" tags: ["luminesce ", "provider", "portfolio", "return"] updated: 2024-08-21T12:47:48Z published: 2024-08-21T12:47:48Z canonical: "support.lusid.com/lusidportfolioreturn" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.lusid.com/llms.txt > Use this file to discover all available pages before exploring further. # Lusid.Portfolio.Return | **Type** | **Read/write** | **Author** | **Availability** | | --- | --- | --- | --- | | [Data provider](/v1/docs/what-are-a-data-provider-and-a-direct-provider) | Read | Finbourne | Provided with LUSID | The `Lusid.Portfolio.Return` provider enables you to write a [Luminesce SQL query](/v1/docs/understanding-the-luminesce-sql-query-syntax) that retrieves [simple performance returns](/v1/docs/aggregating-performance-returns-for-a-portfolio) for one or more LUSID portfolios. > **Note:** The LUSID user running the query must have sufficient [access control permissions](/v1/docs/creating-policies-to-control-access-to-providers-for-different-luminesce-end-users) to both use the provider *and* read portfolio data in LUSID. This should automatically be the case if you are the domain owner. **See also:** [Lusid.Portfolio.AggregatedReturn](/v1/docs/lusidportfolioaggregatedreturn), [Lusid.Portfolio.Return.Writer](/v1/docs/lusidportfolioreturnwriter) ## Basic usage ```sql @lookup_table = ; select * from Lusid.Portfolio.Return where toLookUp = @lookup_table and ``` ## Query parameters `Lusid.Portfolio.Return` has parameters that help you construct a valid table of data to look up. > **Note:** The `toLookUp` parameter is mandatory. Use the following data fields in your `select` statement to identify the portfolios and returns to look up: | **Data field** | **Status** | **Explanation** | | --- | --- | --- | | `PortfolioScope` | Required | The scope of the portfolio to look up. | | `PortfolioCode` | Required | The code of the portfolio to look up. | | `ReturnScope` | Required | The scope of the returns to look up for a portfolio. | | `ReturnCode` | Required | The code of the returns to look up for a portfolio. | | `Period` | Optional | Defaults to `Daily`. Choose `Monthly` to retrieve just monthly returns. | To list all parameters, their data types, default values, and an explanation for each, run the following query using a [suitable tool](/v1/docs/what-tools-are-available-to-write-luminesce-queries): ```sql select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Lusid.Portfolio.Return' and FieldType = 'Parameter'; ``` ## Data fields By default, `Lusid.Portfolio.Return` returns a table of data populated with particular fields (columns). You can return a subset of these fields. To list all fields available to return, their data types, whether fields are considered 'main', and an explanation for each, run the following query using a [suitable tool](/v1/docs/what-tools-are-available-to-write-luminesce-queries): ```sql select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.Portfolio.Return' and FieldType = 'Column'; ``` > **Note:** Fields marked 'main' are returned by queries that start `select ^ from Lusid.Portfolio.Return...` ## Errors We recommend examining the results of every query using the `Error` field. This field is populated if `Lusid.Portfolio.Return` cannot retrieve an entity for some reason. For example, the `Error` field reveals that this query: ```sql @lookup_table = select 'Finbourne-Examples' as PortfolioScope, 'UK-Equities' as PortfolioCode, 'Performance' as ReturnCode; select Error from Lusid.Portfolio.Return where toLookUp = @lookup_table; ``` ...fails because a `ReturnScope` has not been provided in the lookup table. ## Examples > **Note:** For more example Luminesce SQL queries, visit our [Github repo](https://github.com/finbourne/luminesce-examples/tree/master/examples). ### Example 1: Get all daily performance returns for a particular portfolio ```sql @lookup_table = select 'Finbourne-Examples' as PortfolioScope, 'UK-Equities' as PortfolioCode, 'Production' as ReturnScope, 'Performance' as ReturnCode; select Error from Lusid.Portfolio.Return where toLookUp = @lookup_table; ``` ### Example 2: Retrieve monthly loss-making portfolios from last year In this example: - The `Lusid.Portfolio` provider is used to populate values for `PortfolioScope` and `PortfolioCode` in the lookup table, and its `where` clause selects the portfolio scope to retrieve portfolio codes for. - `@@today` and `@@oneYearAgo` demonstrate the use of [scalar variables](/v1/docs/understanding-the-luminesce-sql-query-syntax#variables). ```sql @@today = select date('now'); @@oneYearAgo = select date('now', '-1 year'); @table_of_data = select PortfolioScope, PortfolioCode, 'Production' as ReturnScope, 'Performance' as ReturnCode, 'Monthly' as Period from Lusid.Portfolio where PortfolioScope = 'Finbourne-Examples'; select * from Lusid.Portfolio.Return where toLookUp = @table_of_data and FromEffectiveAt = @@oneYearAgo and UntilEffectiveAt = @@today and RateOfReturn < 0 ```