Lusid.Placement.Writer

Type

Read/write

Author

Availability

Data provider

Write

FINBOURNE

Provided with LUSID

Providing you have sufficient access control permissions, the Lusid.Placement.Writer provider enables you to write a Luminesce SQL query that either upserts or deletes placements in LUSID.

Note: By default, Lusid.Placement.Writer cannot add properties to placements. To do this, you must first configure Lusid.Placement.Writer to 'inline' properties. See how to do this.

You must construct a valid table of data to write, one placement per record. Lusid.Placement.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 one of the following operations:

  • Upsert a placement; that is, create a placement in LUSID if it does not exist, and update it if it does. This is the default operation if you omit WriteAction

  • Delete a placement.

See also: Lusid.Placement

Basic usage

@table_of_data = <select-statement>;
select * from Lusid.Placement.Writer where toWrite = @table_of_data;

Query parameters

Lusid.Placement.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:

select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Lusid.Placement.Writer' and FieldType = 'Parameter';

Data fields

Lusid.Placement.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

Upsert

'Upsert' as WriteAction (or omit)

PlacementScope

PlacementCode

State

Side

TimeInForce

Type

CreatedDate

LimitPrice

LimitPriceCurrency

StopPriceCurrency

Counterparty

Delete

'Delete' as WriteAction

PlacementScope

PlacementCode

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:

select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.Placement.Writer' and FieldType = 'Column';

Write errors

We recommend examining the results of every write query using one or more of the WriteErrorWriteErrorCode and WriteErrorDetail fields.

For each record in the table of data to write, Lusid.Placement.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.

Examples

Note: For more example Luminesce SQL queries, visit our Github repo.

Example 1: Create a placement

Upsert is the default operation if you omit the WriteAction field.

@data_to_write = select 'Finbourne-Examples' as PlacementScope, 'PLACEMENT-1' as PlacementCode, 'Open' as State, 'Buy' as Side, 'LUID_ABCDEFGH' as LusidInstrumentId, 
100 as Quantity, 'GoodTilCancel' as TimeInForce, 'Market' as Type, #2023-06-28# as CreatedDate, 100 as LimitPrice, 'GBP' as LimitPriceCurrency, 'GBP' as StopPriceCurrency, 
'Broker_A' as Counterparty, 'Finbourne-Examples/BLOCK-1' as BlockIds;
select * from Lusid.Placement.Writer where ToWrite = @data_to_write;

Example 2: Create multiple placements in the same scope

@@scope = select 'Finbourne-Examples';
@@currency = select 'GBP';
@@created = select #2023-08-11#;

@placements = values
('PLACEMENT-A', 'Open', 'Buy', 'LUID_00003DDL', 40, 'GoodTilCancel', 'Limit', 100, 'Broker_A'),
('PLACEMENT-B', 'Open', 'Buy', 'LUID_00003DCH', 64, 'Day', 'Limit', 112, 'Broker_B'),
('PLACEMENT-C', 'Open', 'Sell', 'LUID_ABCDEFGH', 100, 'FillOrKill', 'Market', 50, 'Broker_A');

@data_to_write = select @@scope as PlacementScope, column1 as PlacementCode, column2 as State, column3 as Side, column4 as LusidInstrumentId,
column5 as Quantity, column6 as TimeInForce, column7 as Type, @@created as CreatedDate, column8 as LimitPrice, @@currency as LimitPriceCurrency,
@@currency as StopPriceCurrency, column9 as Counterparty from @placements;
select * from Lusid.Placement.Writer where ToWrite = @data_to_write;

Example 3: Delete a placement

@data_to_write = select 'Finbourne-Examples' as PlacementScope, 'PLACEMENT-1' as PlacementCode, 'Delete' as WriteAction;
select * from Lusid.Placement.Writer where ToWrite = @data_to_write;