I am downloading bonds by country, the list of bonds from the US, CN and KR are too long for downloading, so I received different errors (Gateway Time-out, ) every time I try these countries. I was wondering which code kind I use to download these bonds by part if it is not possible to do it in bulk.
This is the code I am using:
#code for the fields
screen1 = 'SCREEN(U(IN(DEALS)/*UNV:DEALSBOND*/),TR.NIisECM=False, IN(TR.NINationHQ(NiDealPartRole=ISUP),'
screen2 = '), CURN=USD)'
#code for the fields
fields_firms = ['TR.NISdcPackageNumber',
'TR.NISdcPackageNumber.DealPackageID',
'TR.NISdcPackageNumber.DealId',
'TR.NISdcPackageNumber.IsTranchePrimary',
'TR.NISdcPackageNumber.SdcDealNumber',
'TR.NISDCTrancheId',
'TR.NIIssueDate',
'TR.NIRedemptionMaturityDate'
]
#code for parameters
parameters_screener = {'curn':'USD', 'NULL':'BLANK'}
ctry_code_list = ['US', 'CN' , 'KR']
# Retrieve firm list and info
firms_ric_list = {}
for ctry in ctry_code_list:
screen = screen1+ctry+screen2
df, err = ek.get_data(screen, fields_firms, parameters_screener)
with pd.ExcelWriter(os.path.join(d_bonds_dir,'screener_bonds_by_phyton.xlsx'), engine='openpyxl',mode='a') as writer:
df.to_excel(writer,sheet_name=ctry)
print(ctry)