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 0 1 5

streaming prices request

asyncio.get_event_loop().run_until_complete(asyncio.sleep(1))

i'm using asyncio loop to remain the ek.StreamingPrices function to remain the data stream open

i need to know since i'm continuously keeping the stream open and sleeping for one second


streaming_prices = ek.StreamingPrices(

instruments = newlist,


fields = ['BID','ASK','TRDPRC_1','ACVOL_1'],


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)

)


streaming_prices.open()


while(true):

asyncio.get_event_loop().run_until_complete(asyncio.sleep(1))

streaming_prices.close()


If we go like above ...and put asyncio call in continuous while loop ....will after 1 second the code will again request for new streaming.open() request and it will be counted as 1 more request or it will just keep the current stream open and will not count it as a seperate request. This i'm asking in context of the number of streaming.open requests we can send in a day ..Also in one request how many instruments i can send for streaming prices . I need to get the AT THE MONEY strike prices of a particular option during a session ...instead of subscribing to all strikes is there a way i can subscribe to ATM strike RIC's in between the session ...I have used above streamingPrices open request only at start of the session .

In addition to that if I want to add one instrument during ongoing streaming prices stream ...how can i do that ....

eikon-data-apipython#technology#productstreaming-pricesasynchronous
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.

Hi @peeush .

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?
If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,
AHS

@peeush

Hi,

Please be informed that a reply has been verified as correct in answering the question, and marked as such.

Thanks,

AHS

Upvote
Accepted
1.3k 3 2 4

Hi @peeush ,

For async usage, you should migtrate to refinitiv-data lib because there is async API.

You can also get example from CodeBook application with the /_Examples__/01.Data Retrieval and Discovery/01.01. Refinitiv Data Library/Content__Pricing_Streaming_Cache.ipynb notebook.

Same example is available in Refinitiv Data Library for Python

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.

About your secondary requests:

  • Also in one request how many instruments i can send for streaming prices.
    => You can open hundreds items but it'll take time to open in 1 time.

  • I need to get the AT THE MONEY strike prices of a particular option during a session ...instead of subscribing to all strikes is there a way i can subscribe to ATM strike RIC's in between the session ...I have used above streamingPrices open request only at start of the session.
    => not sure to understand totally but if you need s trike price without maintaining streaming, you can open a stream with snapshot mode stream.open(with_updates=False)
    You'll only receive the refresh notification and the stream will close automatically

  • In addition to that if I want to add one instrument during ongoing streaming prices stream ...how can i do that ....
    => with pricing stream, you can add/remove item during ongoing streaming.

Thanks for the reply ...2 things to confirm here :

1. in the refinitiv data function i can pricing_stream.open() called to get data ...so once we call this it'll will open the stream and data will keep on coming until we call pricing_stream.close() or something like that to close the stream ?


2. where can i get sample code to see how to add new instrument or delete existing instrument in already opened prices stream .

Upvotes
21 0 1 5

Thanks for the reply ...2 things to confirm here :

1. in the refinitiv data function i can pricing_stream.open() called to get data ...so once we call this it'll will open the stream and data will keep on coming until we call pricing_stream.close() or something like that to close the stream ?


2. where can i get sample code to see how to add new instrument or delete existing instrument in already opened prices stream .

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.

Upvotes
21 0 1 5

Also I have around 50 US Stocks for which i am trying to fetch the prices in stream ...I am getting following output for AAPL.O :


Refresh received for AAPL.O: _UniverseStreams id=0 universe=['AAPL.O', 'ABBV.K', 'ABT', 'ADBE.O', 'AMD.O', 'AMGN.O', 'AMZN.O', 'AVGO.O', 'BA', 'BAC', 'BRKb', 'CMCSA.O', 'COST.O', 'CRM', 'CSCO.O', 'CVX', 'DHR', 'DIS', 'GOOGL.O', 'HD', 'INTC.O', 'INTU.O', 'JNJ', 'JPM', 'KO', 'LLY', 'MA', 'MCD', 'MRK', 'MS', 'MSFT.O', 'NFLX.O', 'NKE', 'NVDA.O', 'ORCL.K', 'PEP.O', 'PFE', 'PG', 'QCOM.O', 'TMUS.O', 'TSLA.O', 'TXN.O', 'UNH', 'V', 'VZ', 'WFC', 'XOM']


this is my code :


pricing_stream = rd.content.pricing.Definition(

universe=[stockslist],

fields=['DSPLY_NAME', 'BID', 'ASK']

).get_stream()


in stock list i have all stocks ...can you please tell why i'm i getting all stocks names in the refresh response for AAPL.O ...i'm getting the same response in all stocks case whereas in your examples: it shows giving proper bid , ask prices ...even if market is closed it should not give this response ..please explain

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.

Upvotes
21 0 1 5

pricing_stream = rd.content.pricing.Definition(

stockslist,

fields=['DSPLY_NAME', 'BID', 'ASK']

).get_stream()



pricing_stream.on_refresh(lambda pricing_stream, instrument_name, fields :

print(f"Refresh received for {instrument_name}: {fields}"))


pricing_stream.on_update(lambda pricing_stream, instrument_name, fields :

print(f"Update received for {instrument_name}: {fields}"))


using this code to get live streaming prices for nifty

stockslist has NIFH4 symbol for nifty ...


Refresh received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']

Update received for NIFH4: _UniverseStreams id=0 universe=['NIFH4']


getting this in response


as per document it should give data like this , sample data :


Refresh received for EUR= : {'DSPLY_NAME': 'BARCLAYS LON', 'BID': 1.1635, 'ASK': 1.1639}

Refresh received for GBP= : {'DSPLY_NAME': 'NEDBANK LTD JHB', 'BID': 1.3803, 'ASK': 1.3807}

Refresh received for CAD= : {'DSPLY_NAME': 'DANSKE BANK COP', 'BID': 1.2351, 'ASK': 1.2352}

Refresh received for JPY= : {'DSPLY_NAME': 'ASANPACIFIBK MOW', 'BID': 113.81, 'ASK': 113.83}

Update received for JPY= : {'DSPLY_NAME': 'NEDBANK LTD JHB', 'BID': 113.81, 'ASK': 113.83}

Update received for CAD= : {'DSPLY_NAME': 'DANSKE BANK COP', 'BID': 1.2351, 'ASK': 1.2352}

Update received for JPY= : {'DSPLY_NAME': 'ASANPACIFIBK MOW', 'BID': 113.81, 'ASK': 113.83}

Update received for EUR= : {'DSPLY_NAME': 'BARCLAYS LON', 'BID': 1.1635, 'ASK': 1.1639}

Update received for CAD= : {'DSPLY_NAME': 'DANSKE BANK COP', 'BID': 1.2351, 'ASK': 1.2352}



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.

Upvotes
79.2k 251 52 74

@peeush

I think the order of properties in lambda is incorrect. It should be:

lambda fields, instrument_name, pricing_stream 

The code looks like this:

pricing_stream1 = rd.content.pricing.Definition(
    ["JPY="],
    fields=['DSPLY_NAME', 'BID', 'ASK']
).get_stream()

pricing_stream1.on_refresh(lambda fields, instrument_name, pricing_stream :
    print(f"Refresh received for {instrument_name}: {fields}"))


pricing_stream1.on_update(lambda fields, instrument_name, pricing_stream :
    print(f"Update received for {instrument_name}: {fields}"))

pricing_stream1.open()

The output is:

1709293866659.png



1709293866659.png (86.1 KiB)
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.

where can i get sample code to see how to add new instrument or delete existing instrument in already opened prices stream .

Upvotes
21 0 1 5

where can i get sample code to see how to add new instrument or delete existing instrument in already opened prices stream .

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.

@peeush

All samples are on GitHub.

You can run the help(pricing_stream1) command to see all available methods.

It has the remove_instruments and add_instruments methods.

Upvotes
21 0 1 5

Hi ,


Can you please provide the exact syntax or the exact github section for the remove_instruments and add_instruments methods.

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.

Upvotes
24.7k 54 17 14

Hello @peeush

Did you try the Python code to generate the library's help information as suggested by @Jirapongse yet?

I have tested it, it works fine on my end.

pricing_stream1 = rd.content.pricing.Definition(
    ["JPY="],
    fields=['DSPLY_NAME', 'BID', 'ASK']
).get_stream()
help(pricing_stream1)

stream-1.png

Then you can scroll down to the remove_instruments and add_instruments methods.

stream-2.png

See more in the comment.


stream-1.png (65.7 KiB)
stream-2.png (32.6 KiB)
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.

stream-3.png

I hope this information helps.

stream-3.png (33.5 KiB)

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.