Type | Read/write | Author | Availability |
Write | Finbourne | Provided with LUSID |
The Lusid.Instrument.Quote.Writer provider enables you to write a Luminesce SQL query that either upserts or deletes one or more quotes to or from the LUSID Quote Store.
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
WriteAction.Delete a quote.
See also: Lusid.Instrument.Quote
Basic usage
@table_of_data = <select-statement>;
select * from Lusid.Instrument.Quote.Writer where toWrite = @table_of_data;Query parameters
Lusid.Instrument.Quote.Writer has parameters that help you construct a valid table of data to write.
Note: The
toWriteparameter 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';Data fields
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 |
Upsert |
|
Delete |
|
Notes on providing values for mandatory fields:
The
Providerfield accepts enumerated values, which includeBloomberg,DataScope,SIX,FactSet,TraderMade,Edi,LusidandClient. If your provider isn't listed, you can represent it usingLusidorClient.For equity and bond prices, use the
InstrumentIdTypefield to specify the required ID type, such asFigi, and theInstrumentIdfield to specify the instrument for the price quote, for exampleBBG000C05BD1.For FX rates, specify
CurrencyPairfor theInstrumentIdTypefield and<baseCurrency>/<quoteCurrency>for theInstrumentIdfield, for exampleUSD/GBP.The
QuoteTypefield accepts enumerated values, which includePrice,Spread,Rate,LogNormalVol,NormalVol,ParSpread,IsdaSpread,Upfront,Index,RatioandDelta.Fieldidentifies the type of price provided such asbid,midorask.
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';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.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.
Examples
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 CurrencyPair:
@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;