|Data provider||Write||Finbourne||Provided with LUSID|
The Lusid.Portfolio.Return.Writer provider enables you to write a Luminesce SQL query that either adds simple performance returns to a portfolio in LUSID, modifies existing returns, or deletes returns.
Note: The LUSID user running the query must have sufficient access control permissions to both use the provider and administer returns in LUSID. This should automatically be the case if you are the domain owner.
You must construct a valid table of data to write, one return per record. Lusid.Portfolio.Return.Writer lists the fields (columns) available to populate with values for each record, and has a set of parameters to help you construct a valid table.
Your query can perform either of the following operations:
- Add new returns or modify existing ones. If a record in your table of data to write contains a return with the same EffectiveAt datetime as one that already exists in LUSID, then the existing return is updated. If not, a new return is added.
- Delete returns between a date range. Note your table of data to write must contain the special WriteAction field with a value of Delete.
Lusid.Portfolio.Return.Writer has parameters that help you construct a valid table of data to write.
Note: The ToWrite parameter is mandatory and used to actually write data to LUSID.
To list available parameters, their data types, default values, and an explanation for each, run the following query using a suitable tool:
Lusid.Portfolio.Return.Writer lists the fields you can populate in your table of data to write.
Depending on the operation you want to perform, the following fields are mandatory to include in the table of data:
|Operation||Mandatory fields in table of data to write|
|Add new or modify existing returns||PortfolioScope, PortfolioCode, ReturnScope, ReturnCode, EffectiveAt, RateOfReturn, Period|
|Delete returns||PortfolioScope, PortfolioCode, ReturnScope, ReturnCode, Period, FromEffectiveAt, UntilEffectiveAt, 'Delete' as WriteAction|
To list all available fields, their data types, whether fields are considered 'main', and an explanation for each, run the following query using a suitable tool:
We recommend examining the results of every write query using one or more of the WriteError, WriteErrorCode and WriteErrorDetail fields.
For each record in the table of data to write, Lusid.Portfolio.Return.Writer returns an error code. If a return is successfully added, modified or deleted, the error code is 0. If unsuccessful, a positive error code and explanation help you discover why LUSID considers the operation invalid.
For example, the query:
...fails because adding a new return must include values for the EffectiveAt, RateOfReturn and Period fields.
Note: For more example Luminesce SQL queries, visit our Github repo.
Example 1: Add a new daily return to a particular portfolio
A new return is added providing a return with an identical EffectiveAt datetime does not already exist in LUSID.
Note that the Period field takes a value of either Daily or Monthly.
Example 2: Delete all returns from the last week
Including 'Delete' as WriteAction in the table of data to write ensures a query performs a delete operation.