for eachId in listOfIds:
    successful = False
while not successful:
    response = makeRequest(eachId)
if response == 'market is closed':
    time.sleep(24 * 60 * 60)
else:
    successful = True
repeat an iteration of for loop