---
title: "Lusid.Portfolio.Holding"
slug: "lusidportfolioholding"
updated: 2024-10-22T14:03:49Z
published: 2024-10-22T14:03:49Z
canonical: "support.lusid.com/lusidportfolioholding"
---

> ## 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.Holding

| **Type** | **Read/write** | **Author** | **Availability** |
| --- | --- | --- | --- |
| [Data provider](/v1/docs/what-are-a-data-provider-and-a-direct-provider) | Read | Finbourne | Provided with LUSID |

Providing you have sufficient [access control permissions](/v1/docs/creating-policies-to-control-access-to-providers-for-different-luminesce-end-users), the `Lusid.Portfolio.Holding` provider enables you to write a [Luminesce SQL query](/v1/docs/understanding-the-luminesce-sql-query-syntax) that generates [holdings](/v1/docs/introduction-to-holdings) from a history of all the transactions and other economic activity in one or more LUSID [transaction portfolios](/v1/docs/what-is-a-transaction-portfolio).

> **Note:** By default, `Lusid.Portfolio.Holding` cannot retrieve properties. To do this, you must first configure `Lusid.Portfolio.Holding` to 'inline' properties. [See how to do this](/v1/docs/how-do-i-configure-luminesce-entity-providers-to-readwrite-properties).

**See also:** [Lusid.Portfolio.Holding.Writer](/v1/docs/lusidportfolioholdingwriter)

## Basic usage

```sql
select * from Lusid.Portfolio.Holding where <filter-expression>;
```

## Query parameters

`Lusid.Portfolio.Holding` has parameters that enable you to filter or refine a query.

To list available 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.Holding' and FieldType = 'Parameter';
```

## Data fields

By default, `Lusid.Portfolio.Holding` returns a table of data populated with particular fields (columns). You can return a subset of these fields.

To list 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.Holding' and FieldType = 'Column';
```

> **Note:** Fields marked 'main' are returned by queries that start select ^ from Lusid.Portfolio.Holding...

## Examples

> **Note:** For more example Luminesce SQL queries, visit our [Github repo](https://github.com/finbourne/luminesce-examples/tree/master/examples).

### Example 1: Generate holdings in every portfolio

```sql
select * from Lusid.Portfolio.Holding
```

### Example 2: Generate holdings in all portfolios in a particular scope, and show instrument friendly names

It's typically useful to join to the `Lusid.Instrument` provider in order to retrieve the friendly name of underlying instruments. Note that since both providers have a `DisplayName` field, only that of `Lusid.Instrument` is returned in order to avoid a duplicate column clash:

```sql
select 
    h.^, 
    i.DisplayName 
from Lusid.Portfolio.Holding h
    left outer join Lusid.Instrument i
    on h.LusidInstrumentId = i.LusidInstrumentId
where PortfolioScope = 'Finbourne-Examples';
```

### Example 3: Generate holdings in a particular portfolio, and retrieve properties

To retrieve properties for holdings, `Lusid.Portfolio.Holding` [must have been configured](/v1/docs/how-do-i-configure-luminesce-entity-providers-to-readwrite-properties) to 'inline' the chosen properties (in this case `CountryOfOrigin`) into the standard set of holdings fields. Note it is possible to retrieve properties from the `Instrument` domain as well as the native `Holding` domain.

```sql
select * from Lusid.Portfolio.Holding 
where PortfolioScope = 'Finbourne-Examples' and PortfolioCode = 'UK-Equities' and CountryOfOrigin <> 'UK'
```

### Example 4: Generate holdings in a particular portfolio every day between two dates

By default, `Lusid.Portfolio.Holding` generates holdings effective today.

- To nominate a different date, specify the `EffectiveAt` parameter.
- To nominate a range of dates and generate holdings on each day in that range, specify the `EffectiveFrom` parameter as the inception date and the `EffectiveAt` parameter as the end date. Note the time component is taken from `EffectiveAt` for every day in the range (see the example below).
- To roll back LUSID's [bitemporal](/v1/docs/what-is-bitemporal-data) *as-at* timeline, specify the `AsAt` parameter.

```sql
--Generate holdings for the last seven days at 12pm
@@x = select Date('now', '-7 day');
@@y = select DateTime(Date('now'), Time('12:00'));
select * from Lusid.Portfolio.Holding 
where PortfolioScope = 'Finbourne-Examples' and PortfolioCode = 'UK-Equities'
and EffectiveFrom = @@x
and EffectiveAt = @@y;
```

> **Note:** Time-variant instrument and holding properties retrieved as part of the query are evaluated each day in a range.

### Example 5: Generate holdings in all portfolios in a particular scope, ignoring those with errors

In this example, holdings are not generated for portfolios containing transactions that have errors, such as unrecognised transaction types.

```sql
select * from Lusid.Portfolio.Holding where PortfolioScope = 'Finbourne-Examples'
and PortfolioCode in ('UK-Equities', 'Portfolio-With-Undefined-Txn-Types')
and Error is null
```
