Hi Team,
Hoping for your help in checking the code of the client below, for some reason, they are not receiving any results when querying for MarketDepth:
Code:
def ExtractRaw(token, json_payload):
try:
outputfilepath = str(_outputFilePath + _outputFileName + str(os.getpid()) + '.csv.gz')
if os.path.exists(outputfilepath):
print(f"File {outputfilepath} already exists. Loading data from local file.")
df = pd.read_csv(outputfilepath, compression='gzip')
else:
_extractRawURL="https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRaw"
_header={}
_header['Prefer']='respond-async'
_header['Content-Type']='application/json; odata.metadata=minimal'
_header['Accept-Charset']='UTF-8'
_header['Authorization']='Token'+token
resp=post(_extractRawURL,data=None,json=json_payload,headers=_header)
if resp.status_code!=200:
if resp.status_code!=202:
message="Error: Status Code:"+str(resp.status_code)+" Message:"+resp.text
raise Exception(message)
_location=resp.headers['Location']
print("Get Status from "+str(_location))
_jobID=""
while True:
resp=get(_location,headers=_header)
_pollstatus = int(resp.status_code)
if _pollstatus==200:
break
else:
print("Status:"+str(resp.headers['Status']))
sleep(_retryInterval) #wait for _retyInterval period and re-request the status to check if it already completed
json_resp = loads(resp.text)
_jobID = json_resp.get('JobId')
_getResultURL = str("https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/RawExtractionResults(/'" + _jobID + "\')/$value")
print("Retrieve result from "+_getResultURL)
resp=get(_getResultURL,headers=_header,stream=True)
response_content = resp.content # This retrieves the response content as bytes
response_size = len(response_content) # Calculate the size in bytes
print(f"Size of response: {response_size} bytes")