Datastream fetch call for multiple securities failing due to no data in one security
I am trying the below Python code to get price index for 50 securities, but it seems the the call is failing because some of the securities do not have history from the starting date, and hence failing to rebalance to 100; one example being UKBJK28Z9. Could you please help me figure this out? The error message Jupyter Notebook is showing is "
could not broadcast input array from shape (3) into shape (50)
"
-----------------------------------------------------------------------------------------------------------------
num_of_sedol_in_each_set = 45
str_fields = 'REB#(X(PI)~U$)'
char_freq = 'M'
first_day_str = '2019-04-16'
last_day_str = '2021-04-15'
isinlist = ['UKBW9RTW0', 'UK6718976', 'UKB01FLR7', 'UK6706250', 'UK6264048', 'UKB2Q5H56', 'UKB4TX8S1', 'UKB1JKTQ6', 'UKB297KM7', 'UKB2PFVH7', 'UKB0BM5T8', 'UKB2R2ZC9', 'UKB1L3XL6', 'UKBYYDFN0', 'UKB1R0FF9', 'UK6241483', 'UKB55ZBQ7', 'UKBF16M83', 'UK6247726', 'UKBD6FLL7', 'UKBJ0RTH3', 'UKBMC5RM7', 'UKBJVJP36', 'UKBLLJ4H7', 'UKB27WRM3', 'UK2579230', 'UK2606440', 'UKB00PV12', 'UKBF2HB11', 'UKBMMV2K8', 'UKB2NR3Y6', 'UK6465874', 'UKB5B23W2', 'UKB4JSTL6', 'UKB4P8HQ1', 'UKB1KYHF2', 'UKBSS6HX7', 'UKB02TT74', 'UKBLD9KX3', 'UKB0FXT17', 'UKBFNLRN6', 'UKBM67GG6', 'UKBYP71J9', 'UKBF4NQP6', 'UKBHHD4Q4', 'UKBYYNH90', 'UKBGJW376', 'UKBF3B6J5', 'UK2579230', 'UKBJK28Z9']
df_prices = pd.DataFrame()
df_prices = ds.fetch(tickers=isinlist, fields=[str_fields], \
date_from= first_day_str, date_to= last_day_str, freq= char_freq)
df_prices
Best Answer
-
I can run the code properly in my environment. The output is:
I also found a duplicated item in the list 'UK2579230'.
Please verify the version of PyDatastream library that you are using. The latest version is 0.6.4. You can get it from https://pypi.org/project/PyDatastream/. The PyDatastream library is a third-party Datastream library that is not from Refinitiv. . Therefore, if you find an issue, please directly contact the library's owner via GitHub.
The Python Datastream library from Refinitiv is DatastreamDSWS.
1
Answers
-
The code runs fine on my environment after removing the following items from the list: UKBMC5RM7, UKBJVJP36, UKBJK28Z9.
0 -
Thanks, jirapongse.phuriphanvichai.
Is it possible to tweak the code so that i can run for all the 50 sedols in the list? This list of sedols get generated by a different process that gets fed to me; so i dont have control on the sedols in the list. Any chance that it is possible to get the output for all the 50 tickers? For the 3 sedols (UKBMC5RM7, UKBJVJP36, UKBJK28Z9) that do not have full history, i would need to rebase those to 100 on the first day when the data was available.
0 -
You can set DS.raise_on_error = False so it will not throw the DatastreamException.
DS.raise_on_error = False
DatastreamException: "UKBMC5RM7"("REB#(X(PI)~U$)"): $$ER: 2361,NO DATA AVAILABLE
0 -
Can you please help me figure out how to write the code regarding raising the error? I tried the code below but could not make it work.
-------------------------------------------------------------------
isinlist = ['UKBW9RTW0', 'UK6718976', 'UKB01FLR7', 'UK6706250', 'UK6264048', 'UKB2Q5H56', 'UKB4TX8S1', 'UKB1JKTQ6', 'UKB297KM7', 'UKB2PFVH7', 'UKB0BM5T8', 'UKB2R2ZC9', 'UKB1L3XL6', 'UKBYYDFN0', 'UKB1R0FF9', 'UK6241483', 'UKB55ZBQ7', 'UKBF16M83', 'UK6247726', 'UKBD6FLL7', 'UKBJ0RTH3', 'UKBMC5RM7', 'UKBJVJP36', 'UKBLLJ4H7', 'UKB27WRM3', 'UK2579230', 'UK2606440', 'UKB00PV12', 'UKBF2HB11', 'UKBMMV2K8', 'UKB2NR3Y6', 'UK6465874', 'UKB5B23W2', 'UKB4JSTL6', 'UKB4P8HQ1', 'UKB1KYHF2', 'UKBSS6HX7', 'UKB02TT74', 'UKBLD9KX3', 'UKB0FXT17', 'UKBFNLRN6', 'UKBM67GG6', 'UKBYP71J9', 'UKBF4NQP6', 'UKBHHD4Q4', 'UKBYYNH90', 'UKBGJW376', 'UKBF3B6J5', 'UK2579230', 'UKBJK28Z9']
ds.raise_on_error = False
df_prices_temp = ds.fetch(tickers=isinlist, fields=["REB#(X(PI)~U$)"], \
date_from= '2019-04-16', date_to= '2021-04-15', freq= 'M')
df_prices_temp
0 -
Thanks, @jirapongse.phuriphanvichai! I will check my setup and try to replicate yours
0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 162 App Studio
- 4 Block Chain
- 5 Bot Platform
- 17 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
- 370 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
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛