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