Refinitiv Data Library for TypeScript

Pricing.StreamEvent

Summary

Pricing.StreamEvent provides a set of events described below that can be emitted by Pricing.Stream

Events

Pricing.StreamEvent.Refresh

Description: Refresh events are emitted for each requested instrument when all fields are received.
This complete list of the fields is sometimes called the 'image' of the instrument. This image that comes with Refresh messages can be later updated by subsequent Update events.
When several Refresh events are received for the same instrument, the fields transported by the latest Refresh are considered as the new image. Fields received in previous Refresh-events or Update-events must be discarded.
Pricing.Stream objects automatically manage this logic for their internal cache, meaning that when you call getFields you always get the latest and relevant field values for the requested instrument.

Parameters:

  • The new fields and values of the Image
  • Name of the instrument
  • The Pricing.Stream object that emitted the event

Pricing.StreamEvent.Update

Description: Update events are emitted for each requested instrument when fields are changed. Update events only contain the fields and values that changed. When the application receives an Update it must update its internal representation of the instrument (if any) accordingly.
Pricing.Stream objects automatically manage this logic for their internal cache, meaning that when you call getFields you always get the latest values of the requested instrument.

Parameters:

  • The updated fields with their new values
  • Name of the instrument
  • The Pricing.Stream object that emitted the event

Side note: As Refresh events and Update events use event handlers with the same signature, the same handler can be used for these 2 event types if you do not need to distinguish them.

Pricing.StreamEvent.Status

Description: Status events are emitted when the status of one of requested instruments changes.

Parameters:

  • The new status of the stream
  • Name of the instrument
  • The Pricing.Stream object that emitted the event

Pricing.StreamEvent.Complete

Description: Complete event is emitted once all the requested instruments received either a Refresh or a Status event.
The Complete event indicates that the all the instrument streams objects are Complete and that internal cache of all pricing instrument streams contain the full data set (instruments and fields) that were requested.

Parameters:

  • The Pricing.Stream object that is Complete

Pricing.StreamEvent.Error

Description: Error event is emitted when an error message is received for some of the requested instruments.

Parameters:

  • Error object that contains an error message and a name
  • The Pricing.Stream object that emitted the event

Examples of usage:

pricingStream.on(Pricing.StreamEvent.Refresh, (fields, name, sp) => console.log(`Refresh event - New fields for ${name}:`, fields));

pricingStream.on(Pricing.StreamEvent.Update, (fields, name, sp) => console.log(`Update event - Updated fields for ${name}:`, fields));

pricingStream.on(Pricing.StreamEvent.Status, (state, name, sp) => console.log(`Status event for ${name}:`, state));

pricingStream.on(Pricing.StreamEvent.Complete, sp => console.log('Complete event'));

pricingStream.on(Pricing.StreamEvent.Error, (err, sp) => console.log(`Error event for ${err.name}:`, err));

There are also additional methods for subscriptions.
They all are aliases for the appropriate .on() method showed above.

pricingStream.onRefresh((fields, name, sp) => console.log(`Refresh event - New fields for ${name}:`, fields));

pricingStream.onUpdate((fields, name, sp) => console.log(`Update event - Updated fields for ${name}:`, fields));

pricingStream.onStatus((state, name, sp) => console.log(`Status event for ${name}:`, state));

pricingStream.onComplete(sp => console.log('Complete event'));

pricingStream.onError((err, sp) => console.log(`Error event for ${err.name}:`, err));