Error when trying to convert the result from historic.pricing to dataframe

Hi, I'm using the python lseg library and the historic_pricing module. When getting the result and converting it to dataframe, I am getting the error:
ndexError Traceback (most recent call last)
Cell In[7], line 2
1 response = historical_pricing.summaries.Definition(TT).get_data()
----> 2 response.data.df
File c:\Users\Public\Programs\Python_64bit_3.10.04\lib\site-packages\lseg\data\content\_content_data.py:18, in Data.df(self)
15 @property
16 def df(self):
17 if self._dataframe is None:
---> 18 self._dataframe = self._dfbuilder(self.raw, **self._kwargs)
20 return self._dataframe
File c:\Users\Public\Programs\Python_64bit_3.10.04\lib\site-packages\lseg\data\content\_historical_df_builder.py:402, in HistoricalBuilder.build(self, raws, universe, fields, axis_name, use_multiindex, **_)
398 return pd.DataFrame()
400 bad_raws.insert_to(listofcolumns)
--> 402 data, columns, index = items_by_date.process_data(len(raws), listofcolumns, use_multiindex)
404 index = pd.Index(data=index, name=axis_name)
405 df = pd.DataFrame(data=data, columns=columns, index=index)
File c:\Users\Public\Programs\Python_64bit_3.10.04\lib\site-packages\lseg\data\content\_historical_df_builder.py:301, in ItemsByDate.process_data(self, num_raws, listofcolumns, use_multiindex)
299 right_idx = left_idx + len(raw_columns)
300 for item, i in zip(raw_data, range(left_idx, right_idx)):
--> 301 template[i] = item
303 index_append(date)
304 data_append(template)
IndexError: list assignment index out of range
The strange thing about this is that this error occurs when passing some lists of instruments and depending on the order of the list the code works. For example, if I pass "PETR4.SA" as the first item in the list, the code works, but when passing it as the last item, I receive the mentioned error.
This is my code:
import lseg.data as ld
from lseg.data.content import historical_pricing
TT = ['SX3',
'.BNPIUIL5',
'LHJ24',
'CCMF25',
'PETR4.SA']
response = historical_pricing.summaries.Definition(TT).get_data()
response.data.df
Could you help me with how I can get around this problem? My goal is to pass a list with about a thousand different tickers
Best Answer
-
Thank you for reaching out to us.
I found that 'SX3', '.BNPIUIL5', and 'LHJ24' are invalid instruments.
The API doesn't work when the first item is invalid. Please contact the helpdesk team directly via MyAccount to verify the instruments.
0
Answers
-
Thanks for the quick response!!
Is there any call I can make to check if the instrument is valid? Do you have any recommendations for good practice or what is commonly used by other users?0 -
@Jirapongse
I don't know if the notification will reach you, so this message is just to mark you0 -
You can try the get_data method.
ld.get_data(
universe= ['SX3','.BNPIUIL5','LHJ24','CCMF25','PETR4.SA'],
fields=['TR.RIC']
)0 -
@Jirapongse
Your suggestion helped me, thank you! However, I still had one doubt. There is the symbol_conversion method. I did a test and gave him the "SX3" instrument. It should return the RIC, but it returned an empty dataframe
This is my code:response = symbol_conversion.Definition("SX3").get_data()
response.data.df
Why did it return empty? Why using the symbol_conversion method returns empty and following ld.get_data(
universe= ['SX3'],
fields=['TR.RIC']
) does it work? Is this expected?
0 -
They are using the different services or endpoints so the behaviors can be different.
SX3 is expired so it is not valid RIC anymore. It has been renamed to SX3^2. I think this is why symbol_conversion can't convert this RIC.
0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 630 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 86 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛