In Terminal I try to run my python file that should download a large quantity of data as a CSV file.
I get the error code 408. Something about a JSON request. How do I fix this?
(base) U:\Castellain\refinitiv>python dailyAPIcode.py
Request timeout occured
Traceback (most recent call last):
File "dailyAPIcode.py", line 25, in <module>
'TR.RNSARPctOSPostTrans'])
File "C:\Users\william\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\data_grid.py", line 186, in get_data
result = eikon.json_requests.send_json_request(_endpoint, payload, debug=debug)
File "C:\Users\william\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\json_requests.py", line 118, in send_json_request
_check_server_error(result)
File "C:\Users\william\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\json_requests.py", line 194, in _check_server_error
raise EikonError(int(server_response['ErrorCode']), error_message)
eikon.eikonError.EikonError: Error code 408 | Request timeout occured
FROM THE .PY FILE:
#import packages
import eikon as ek # the Eikon Python wrapper package
import pandas as pd
import numpy as np
import datetime
from datetime import timedelta, date, datetime
from pandas.tseries.offsets import BDay
#connects to Bill's Eikon terminal
ek.set_app_key('xxxxxxxxxxxxxxxxxxxxx')
#Buyback fields with dynamic date constraints for a list of RICs AND export as CSV to U:Castellain/refinitiv
df,e = ek.get_data("lists('Inv Trust List')","TR.RIC")
ric_list = df['Instrument'].tolist()
df, e = ek.get_data(ric_list,
['TR.RNSFilerName',
'TR.RNSAnnouncedDate',
'TR.RNSTransactionType',
'TR.RNSARNumShrsTransacted',
'TR.RNSARPctOSTransacted',
'TR.RNSARTransactionPrice',
'TR.RNSARMktValTransaction',
'TR.RNSARTotShrsPostTrans',
'TR.RNSARPctOSPostTrans'])
end_date = date.today()
start_date = end_date - timedelta(days=365)
end_date_str = datetime.strftime(end_date, "%Y-%m-%d")
start_date_str = datetime.strftime(start_date, "%Y-%m-%d")
df['RNS Announced Date'] = pd.to_datetime(df['RNS Announced Date'])
mask = (df['RNS Announced Date'] > start_date_str) & (df['RNS Announced Date'] <= end_date_str)
df = df.loc[mask]
df.rename(columns={'RNS AR Price (at Transaction) - £': 'RNS AR Price (at Transaction) GBP',
'RNS AR Market Value of Transaction - £': 'RNS AR Market Value of Transaction - GBP'},
inplace=True)
#create file name and export
todays_date = date.today()
todays_date_str = datetime.strftime(todays_date, "%Y%m%d")
df.to_csv('Daily API Download_' + todays_date_str + '.csv')