LSEG Data Library for TypeScript

HistoricalPricing.TimeSeries.Definition methods

getStream

This method creates and returns the time series stream that allows you to retrieve the historical pricing events or summaries.

Syntax

definition.getStream(session?: Session)

Parameters

Value Description Data type Optional Default value
session Session object. If it's not passed the default session will be used. Session Yes -

Returned value

HistoricalPricing.TimeSeries.Stream.Stream object.

Usage

The following example demonstrates how to retrieve the historical pricing summaries for 'VOD.L' universe as time series stream.

const definition = HistoricalPricing.TimeSeries.Definition(
    'Summaries',
    {
        universe: 'VOD.L',
        fields: ['TRDPRC_1'],
        interval: HistoricalPricing.Summaries.IntradayInterval.ONE_MINUTE,
        start: '2024-01-14T00:00:00.000Z',
        end: '2024-02-17T00:00:00.000Z',
        sessions: ['normal'],
        adjustments: ['exchangeCorrection', 'manualCorrection', 'CCH', 'CRE', 'RPO', 'RTS'],
        summaryTimestampLabel: 'startPeriod',
    }
);

const stream = definition.getStream(session);

stream.onInsert((update) =>  {
        update.table[0].data?.forEach(item => {
            console.log('on insert: ', item);
        })
    })
    .onRefresh((event) => console.log('on refresh: ', event))
    .onComplete(() => console.log('Complete'))
    .onError(err => console.log('Error: ', err.message))
    .open();
{
    "defaultPricingField": "OFF_CLOSE",
    "qos": 1,
    "headers": [
        {"name": "DATE","type": "string"},{"name": "TRDPRC_1","type": "number","decimalChar": "."},{"name": "MKT_HIGH","type": "number","decimalChar": "."}
    ],
    "data": [
        ["2024-02-13", 64.02, 64.93], ["2024-02-12", 63.628, 64.253], ["2024-02-09", 63.196, 63.91,]
    ]
}

None.

67 words (0:21 mins)