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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 0

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-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
icon clock
10 |1500

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

1 Answer

Upvotes
Accepted
38.1k 69 35 53

@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 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea