Python code to pull the TimeAndSales RIC data

Hi,
After receiving status_code = 200, what is the correct way to pull the data based on JobId in my code below?
print(f'Received status code which is not 202: {request_status}')
# Successful
if request_status == 200:
print("Received status code 200")
keys = resp.json().keys()
if 'JobId' in keys:
JobId = resp.json()['JobId']
extract_url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/RawExtractionResults"
import pdb
pdb.set_trace()
resp1 = requests.get(extract_url + "('" + JobId + "')/$value", headers=request_headers)
print("result:", resp1)
return resp1
else:
print(keys)
print(resp.json())

Best Answer

  • zoya faberov
    zoya faberov ✭✭✭✭✭
    Answer ✓

    Hello @dilip.kha ,

    Have you downloaded examples RTH Python Code Samples ?

    Are you looking at the example OnDemand_IntradayBars.py?

    Do you see in code:

    #Step 4: get the extraction results, using the received jobId.
    #Decompress the data and display it on screen.
    #Skip this step if you asked for a large data set, and go directly to step 5 !

    Prior to this in

    #Step 2: send an on demand extraction request using the received token 

    Is where I was suggesting to replace TickHistoryIntradaySummariesExtractionRequest with your required request.

    ---

    I have adapted this sample for T&S use before, perhaps you will find this change useful, please find it attached.

    RTH_OnDemand_TS.py.zip

Answers