Dear LSEG Support Team,
I am currently developing a Performance Attribution tool using the lseg.data Python library but I have a problem when loading past prices; when running my code below, the requested fields return the same data regardless of the specified past date.
my code :
def fetch_all_dates(rics, dates):
fields = [
"TR.FIPrice", 'TR.FIAccruedInterest', 'TR.ModifiedDurationAnalytics', "TR.ZSPREAD",
"TR.YieldToMaturity"
]
all_market_data = {}
for d in dates:
print(f"\n--- Extraction for date {d} ---")
temp_list = []
for r in rics:
try:
# Retrieval test
df_res = ld.get_data(
universe=r,
fields=fields,
parameters={'SDate': d}
)
if df_res is not None:
temp_list.append(df_res)
except Exception as e:
# HERE: Show the actual error
print(f"Skipping instrument {r}. LSEG reason: {str(e)}")
continue
# We group all successfully retrieved instruments for this date
if temp_list:
final_df_date = pd.concat(temp_list, ignore_index=True)
# Renaming with the date
final_df_date = final_df_date.rename(columns=lambda x: f"{x}_{d}" if x != 'Instrument' else x)
all_market_data[d] = final_df_date
return all_market_data
Do you know what is the probleme or how could I proceed to collect market data at different past dates ?
Thank you in advance for your help