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)?