I am registering a service to get live market data, but when I run following code it finishes after one update only
def display_refreshed_fields(streaming_price, instrument_name, fields):
current_time = datetime.datetime.now().time()
print(current_time, "- Refresh received for", instrument_name, ":", fields)
def display_updated_fields(streaming_price, instrument_name, fields):
current_time = datetime.datetime.now().time()
print(current_time, "- Update received for", instrument_name, ":", fields)
def display_status(streaming_price, instrument_name, status):
current_time = datetime.datetime.now().time()
print(current_time, "- Status received for", instrument_name, ":", status)
def display_complete_snapshot(streaming_prices):
current_time = datetime.datetime.now().time()
print(current_time, "- StreamingPrice is complete. Full snapshot:")
print(streaming_prices.get_snapshot())
streaming_prices = ek.StreamingPrices(
instruments=["NIRc1", "NEUc1"],
fields=["SALTIM_MS", "TRDPRC_1", "TRDVOL_1"],
service='IDN_RDF',
on_refresh = lambda streaming_price, instrument_name, fields :
display_refreshed_fields(streaming_price, instrument_name, fields),
on_update = lambda streaming_price, instrument_name, fields :
display_updated_fields(streaming_price, instrument_name, fields),
on_status = lambda streaming_price, instrument_name, status :
display_status(streaming_price, instrument_name, status),
on_complete = lambda streaming_price :
display_complete_snapshot(streaming_price)
)
streaming_prices.open()
streaming_prices.get_snapshot()
output is as follows : -
14:44:06.201053 - Status received for NEUc1 : {'status': <StreamState.Open: 3>, 'code': 'Open', 'message': 'All is well'}
14:44:06.201993 - Refresh received for NEUc1 : {'SALTIM_MS': 33223000, 'TRDPRC_1': 87.6225, 'TRDVOL_1': 5}
14:44:06.204055 - Status received for NIRc1 : {'status': <StreamState.Open: 3>, 'code': 'Open', 'message': 'All is well'}
14:44:06.205031 - Refresh received for NIRc1 : {'SALTIM_MS': 33244000, 'TRDPRC_1': 74.3925, 'TRDVOL_1': 1}
14:44:06.206042 - StreamingPrice is complete. Full snapshot:
Instrument SALTIM_MS TRDPRC_1 TRDVOL_1
0 NIRc1 33244000 74.3925 1
1 NEUc1 33223000 87.6225 5