Tutorial Source Code |
Example: 3.1.01-Streaming-MarketPrice |
Last Update | May 2021 |
.NET/C# Requirements | See Getting Started with .NET. |
Pre-requisites | Enable the session environment as outlined within the Getting Started guide. To build and run the above example:
|
Whether accessing from the desktop, directly to the cloud, or through your deployed managed streaming services, the Refinitiv Data Libraries provide ease-of-use interfaces to retrieve real-time streaming content from the platform. By utilizing the streaming interfaces, developers can easily define both basic and advanced properties to request, receive, and process market data in real-time.
The following tutorial will outline sample code that provides basic access to level 1 (MarketPrice) streaming content. The library defines an interface necessary to make WebSocket connections to Refinitiv Real-Time Distribution Systems, and, to Refinitiv Real-Time -- Optimized (cloud offering).
Running the example application will display the initial refresh image for the EUR= instrument. As market conditions change, you will see real-time events generated and displayed to the console.
Within the source code package, select the source code example within the Delivery section. To execute the example, refer to the pre-requisites section at the top of this tutorial.
The expected output should look similar to this:
The first step required to access data from the platform is to establish a session. For convenience and simplicity, each example will utilize the following code segment to establish a session based on your package settings.
The Session defines the interface for a specific channel which indicates how to access the platform. Each session defines unique properties that generally include user credentials and connection details. Once defined, a call to open() attempts to authenticate and manage any connection resources required.
Once a session has been established, you are free to access the available data services offered for the specified access channel. In this tutorial, we are interested in accessing streaming data services.
The following code segment outlines the basic syntax when defining s stream:
The OMMStream refers to the streaming services provided by the platform to retrieve OMM-based market streaming data. The interface provides a Definition that accepts multiple settings necessary to access financial market data. To open a stream and retrieve real-time updates, the interface defines a GetStream interface to provide the details related to capturing real-time events, such as market data updates. In this tutorial, we present the minimum properties to demonstrate streaming level 1 (MarketPrice) data to the application. The specified properties are:
Definition
The Definition accepts the item of interest, i.e. 'EUR='.
Stream
The Stream interface provides the following lambda expressions or callbacks. Each callback is provided 3 parameters, i.e.
To capture real-time events, the following callbacks are provided:
Note: By default, update events will be sent to your stream. If there is only interest in receiving the initial image (snapshot), the behavior can be overridden using the Streaming() method call.
Status events can be reported throughout the life of the stream. Refer to Visual Studio IntelliSense for the entire list of methods and properties available.
While the Streaming interface does support additional properties, the syntax outlined above will cover the core features needed to request and process streaming content required by this tutorial. By default, the interface will choose to stream a level 1 MarketPrice message to include all fields defined for the specified name.
Note: The open() call is a synchronous call and will return once the request has completed. A request to open a stream is considered complete when the initial response (refresh or status) has returned for the specified item name.