Hi all,
I am trying to retrieve an historical time series for certain fields of corporate bonds, however it only returns me the latest value
fields = [
'TR.PriceClose.date',
'TR.FiIssueDate(SEG=G)',
'TR.FiMaturityYearsToRedem',
'TR.NICouponRate',
'COUPN_RATE',
'TR.CouponRate',
'EFF_DURTN',
'DURATION',
'TR.MODIFIEDDURATION',
'TR.IssueSizeUSD',
'TR.CA.AmtOutstanding(SDate=0M)',
'TR.OPTIONADJUSTEDSPREAD(SDate=0M)',
'TR.OASAnalytics',
]
for i in range(0, len(ric_bonds), chunk_size):
chunk = ric_bonds[i:i + chunk_size]
try:
df = ld.get_data(
universe=chunk, # Fetch data for this chunk only
fields=fields,
parameters={'SDate': '2010-01-31', 'EDate': '2024-12-31', 'Frq': 'M'}
)
except Exception as e:
conitnue
all_data = pd.concat([all_data, df], ignore_index=True)
all_data.to_csv('xxx.csv', index=False)
print(f"Processed chunk {i // chunk_size + 1} of {len(ric_bonds) // chunk_size + 1}")
# Sleep between chunks
time.sleep(sleep_time)
all_data.to_csv('final_bond_chars.csv', index=False)
print("Data processing complete. File saved as 'xxxx.csv'.")