Refinitiv Data Library for Python

trade data service stream.on_state

Called when the state of one of the requested entities changes.

Module

refinitiv.data.content.trade_data_service

Syntax

stream.on_state(func)

Parameters

Value Description Data type Optional Default value
func Callable object to process the retrieved data. Callable No -

Returned value

trade data service Stream object

Usage

The following example demonstrates how to display messages received when the state of one of the requested entities changes.

import datetime


# previously defined callable, pay attention that arguments order is important
def func(event, stream):
    current_time = datetime.datetime.now().time()
    print("----------------------------------------------------------")
    print(">>> {} event received at {}".format("Add", current_time))
    print(event)


stream = trade_data_service.Definition(
    universe="LSEG.L",
    fields=["OrderKey", "OrderTime"]
).get_stream()

stream.on_state(func)
stream.open()

None.