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 ....
Best Answer
-
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
1
Answers
-
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.
0 - Also in one request how many instruments i can send for streaming prices.
-
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 .
0 -
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
0 -
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 .
0 -
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}
0 -
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:
0 -
where can i get sample code to see how to add new instrument or delete existing instrument in already opened prices stream .
0 -
where can i get sample code to see how to add new instrument or delete existing instrument in already opened prices stream .
0 -
-
Hi ,
Can you please provide the exact syntax or the exact github section for the remove_instruments and add_instruments methods.
0 -
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)Then you can scroll down to the remove_instruments and add_instruments methods.
See more in the comment.
0 -
I hope this information helps.
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛