|Data provider||Write||Finbourne||Provided with LUSID|
Note: The LUSID user running the query must have sufficient access control permissions to both use the provider and upsert or delete quote data 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 quote per record.
Lusid.Instrument.Quote.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 quote; that is, create a quote if it does not exist, and update it if it does. This is the default operation if you omit
- Delete a quote.
See also: Lusid.Instrument.Quote
@table_of_data = <select-statement>; select * from Lusid.Instrument.Quote.Writer where toWrite = @table_of_data;
Lusid.Instrument.Quote.Writer has parameters that help you construct a valid table of data to write.
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.Instrument.Quote.Writer' and FieldType = 'Parameter';
Lusid.Instrument.Quote.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|
Notes on providing values for mandatory fields:
Providerfield accepts enumerated values, which include
Client. If your provider isn't listed, you can represent it using
- For equity and bond prices, use the
InstrumentIdTypefield to specify the required ID type, such as
Figi, and the
InstrumentIdfield to specify the instrument for the price quote, for example
- For FX rates, specify
InstrumentIdfield, for example
QuoteTypefield accepts enumerated values, which include
Fieldidentifies the type of price provided such as
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.Instrument.Quote.Writer' and FieldType = 'Column';
We recommend examining the results of every write query using one or more of the
For each record in the table of data to write,
Lusid.Instrument.Quote.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:
@table_of_data = select 'FinbourneMarketData' as QuoteScope, 'Lusid' as Provider, 'BBG000DMBXR2' as InstrumentId, 'Figi' as InstrumentIdType, 'Price' as QuoteType, 'mid' as Field, 117.09 as Value, #2022-07-11# as QuoteEffectiveAt; select WriteErrorCode, WriteError, WriteErrorDetail from Lusid.Instrument.Quote.Writer where toWrite = @table_of_data;
...fails because a
Unit is not specified.
Note: For more example Luminesce SQL queries, visit our Github repo.
Example 1: Upsert a USD/GBP exchange rate quote for a particular effective date
In this example, the instrument identifier type is
@table_of_data = select 'FinbourneMarketData' as QuoteScope, 'Lusid' as Provider, 'USD/GBP' as InstrumentId, 'CurrencyPair' as InstrumentIdType, 'Rate' as QuoteType, 'mid' as Field, 0.82 as Value, 'GBP' as Unit, #2022-07-08# as QuoteEffectiveAt; select * from Lusid.Instrument.Quote.Writer where ToWrite = @table_of_data;
Example 2: Delete an existing USD/GBP exchange rate quote
In this example, the explicit use of
'Delete' as WriteAction performs the delete operation:
@table_of_data = select 'FinbourneMarketData' as QuoteScope, 'Lusid' as Provider, 'USD/GBP' as InstrumentId, 'CurrencyPair' as InstrumentIdType, 'mid' as Field, #2022-07-08# as QuoteEffectiveAt, 'Delete' as WriteAction; select * from Lusid.Instrument.Quote.Writer where ToWrite = @table_of_data;