import time import eikon as ek ek.set_app_key('In here with your app key...') static_flds = ['TR.IndexConstituentRIC', 'TR.IndexConstituentName'] for x in range(100): print('round: ', x) err_const = 0 # random stuff err_isin = 0 # random stuff again while err_const is not None: try: inst_list, err_const = ek.get_data(instruments=['.STOXX'], fields=static_flds, parameters={'SDate': '2017-01-15', 'EDate': '2017-01-15'}) except: pass while err_isin is not None: try: isin_list, err_isin = ek.get_data(instruments=inst_list.loc[:, 'Constituent RIC'].tolist(), fields=['TR.ISINCode', 'TR.SEDOL']) except: pass if (isin_list['ISIN Code'].values == '').sum() > 0: print(isin_list.head(5)) print('Weird stuff going on in this loop!') print() time.sleep(2) print('end')