Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
21 1 1 1

Streaming quotes

I am trying to get streaming prices to run continuously. I followed the tutorial that Refinitiv had posted, but I was unable to figure out how to get the loop to run continuously.

https://github.com/Refinitiv-API-Samples/Tutorial.EikonAPI.Python.Streaming/blob/master/02%20-%20Eikon%20Data%20API%20-%20StreamingPrices%20with%20events.ipynb



I was trying to use the code as posted. However, it only ran once and terminated. I thought about using a continuous loop, but it seems like I shouldn’t be calling this function continuously. I thought that I should just call it once, call the streaming_prices.open() function, and then sit back and let the price data just flow in.


streaming_prices = ek.StreamingPrices(

instruments = ['EUR=','GBP=','JPY=', 'CAD='],

fields = ['SALTIM', 'CF_BID','CF_ASK','OPEN_PRC', 'CF_HIGH','CF_LOW', 'CF_CLOSE'],

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)

)


Can you explain what is the proper way of setting up this loop to get streaming prices continuously (running continuously until the user terminates the program)?

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@puri

Hi,

Thank you for your participation in the forum.

Is the reply below satisfactory in answering your question?

If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

1 Answer

· Write an Answer
Upvotes
Accepted
78.6k 248 52 74

@puri

I assume that you would like to run the code in a console application.

You can use the asyncio package, as shown below.

import asyncio
...
...
streaming_prices.open()
    
asyncio.get_event_loop().run_forever()
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.