streaming price service is printing just one update
I am registering a service to get live market data, but when I run following code it finishes after one update only
def display_refreshed_fields(streaming_price, instrument_name, fields):
current_time = datetime.datetime.now().time()
print(current_time, "- Refresh received for", instrument_name, ":", fields)
def display_updated_fields(streaming_price, instrument_name, fields):
current_time = datetime.datetime.now().time()
print(current_time, "- Update received for", instrument_name, ":", fields)
def display_status(streaming_price, instrument_name, status):
current_time = datetime.datetime.now().time()
print(current_time, "- Status received for", instrument_name, ":", status)
def display_complete_snapshot(streaming_prices):
current_time = datetime.datetime.now().time()
print(current_time, "- StreamingPrice is complete. Full snapshot:")
print(streaming_prices.get_snapshot())
streaming_prices = ek.StreamingPrices(
instruments=["NIRc1", "NEUc1"],
fields=["SALTIM_MS", "TRDPRC_1", "TRDVOL_1"],
service='IDN_RDF',
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)
)
streaming_prices.open()
streaming_prices.get_snapshot()
output is as follows : -
14:44:06.201053 - Status received for NEUc1 : {'status': <StreamState.Open: 3>, 'code': 'Open', 'message': 'All is well'}
14:44:06.201993 - Refresh received for NEUc1 : {'SALTIM_MS': 33223000, 'TRDPRC_1': 87.6225, 'TRDVOL_1': 5}
14:44:06.204055 - Status received for NIRc1 : {'status': <StreamState.Open: 3>, 'code': 'Open', 'message': 'All is well'}
14:44:06.205031 - Refresh received for NIRc1 : {'SALTIM_MS': 33244000, 'TRDPRC_1': 74.3925, 'TRDVOL_1': 1}
14:44:06.206042 - StreamingPrice is complete. Full snapshot:
Instrument SALTIM_MS TRDPRC_1 TRDVOL_1
0 NIRc1 33244000 74.3925 1
1 NEUc1 33223000 87.6225 5
Best Answer
-
Is there anyother code after the
- streaming_prices.open()
- streaming_prices.get_snapshot()
to keep the script/code running? Otherwise, the script will terminate.
If not, then you should add something like:
asyncio.get_event_loop().run_until_complete(asyncio.sleep(60))
that will run for 60 seconds, you can add the above to a loop to run for longer...
1
Answers
-
@birendra.bisht1 Please remove the last line:
- streaming_prices.get_snapshot()
and run and it should work fine. The snapshot just pulls the current snapshot and provides no updates. I hope this can help.
0 -
I should point out that my reply above is assuming that you are running a .py file and NOT inside a Jupyter Notebook? If you are running in a Jupyter env, then you should continue to receive updates as Jupyter keeps things ticking over.
0 -
Hi @umer.nalla thanks for your answer.
0
Categories
- All Categories
- 6 AHS
- 38 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 中文论坛