Hi,
I am trying to retrieve the daily stock prices from a certain stock. Below you can see my code. The problem is that on a certain day like weekend or holiday I am receiving the following error message which makes sense "NSUG.DE: No data available for the requested date range". Is there a possibility that I can ignore those days and my code does not run into an error?
#date modfication
start_date = datetime(2020, 1, 1, tzinfo=timezone.utc)
end_date = datetime(2020, 7, 10, tzinfo=timezone.utc)
date_range = pd.date_range(start=start_date, end=end_date, freq='D')
#RIC, fields, time to receive stock prices
rics = ['NSUG.DE']
fields = ['OPEN','HIGH','LOW','CLOSE','VOLUME']
for date in date_range:
sdate = str(date)[0:10] + 'T07:00:00'
edate = str(date)[0:10] + 'T22:01:00'
df = ek.get_timeseries(rics=rics,
fields=fields,
start_date=sdate,
end_date=edate,
interval='minute')
print(df)
#safe to csv
df.to_csv('test' + str(date)[0:10] + '.csv')