Type | Read/write | Author | Availability |
---|---|---|---|
Write | FINBOURNE | Provided with LUSID |
Providing you have sufficient access control permissions, the Lusid.Portfolio.Txn.Writer
provider enables you to write a Luminesce SQL query that either upserts or deletes transactions to or from transaction portfolios.
Note: By default,
Lusid.Portfolio.Txn.Writer
cannot add properties to transactions. To do this, you must first configureLusid.Portfolio.Txn.Writer
to 'inline' properties. See how to do this.
You must construct a valid table of data to write, one transaction per record. Lusid.Portfolio.Txn.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 use the WriteAction
field to perform either of the following operations:
Upsert a transaction; that is, create a transaction if the
TxnId
is not yet registered with the portfolio, and update it if it is. More on this operation.Delete (that is, cancel) a transaction. More on this operation.
See also: Lusid.Portfolio.Txn
Basic usage
Query parameters
Lusid.Portfolio.Txn.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 the table of data into LUSID.
To list available parameters, their data types, default values, and an explanation for each, run the following query using a suitable tool:
Data fields
Lusid.Portfolio.Txn.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 | Specify using... | Mandatory fields in table of data to write |
---|---|---|
Upsert |
|
|
Delete |
|
|
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:
Write errors
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.Txn.Writer
returns an error code. If the operation is successful, 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 a TxnId
is not specified.
Examples
Note: For more example Luminesce SQL queries, visit our Github repo.
Example 1: Upsert a transaction in an equity to a portfolio
In this example, the instrument identifier is a non-currency LUID.
Example 2: Upsert a transaction in a currency to a portfolio
In this example, the instrument identifier is a currency LUID.
Example 3: Upsert multiple transactions to multiple portfolios, and add properties
Note that to add or change transaction properties, Lusid.Portfolio.Txn.Writer
must have been configured to 'inline' the chosen properties (in this case BrokerCommission
) into the standard set of transaction fields.