question

Upvotes
1 0 0 0

Slow querying of DDS intraday summaries

I have used the Python Example code to query intraday summaries. It takes 4 minutes to download the basic data for 24 hour period for 2 stocks. How can this be optimised?


def request_intraday_summaries(token, rics, start_date, end_date):

url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractRaw"

headers = {

"Prefer": "respond-async",

"Content-Type": "application/json",

"Authorization": f"token {token}"

}

# Define the content fields you want to retrieve

content_fields = [

"Volume",

"Last",

]

# Build the request body

body = {

"ExtractionRequest": {

"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.TickHistoryIntradaySummariesExtractionRequest",

"ContentFieldNames": content_fields,

"IdentifierList": {

"@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",

"InstrumentIdentifiers": [{"Identifier": ric, "IdentifierType": "Ric"} for ric in rics],

"UseUserPreferencesForValidationOptions": False

},

"Condition": {

"MessageTimeStampIn": "GmtUtc",

"ReportDateRangeType": "Range",

"QueryStartDate": start_date,

"QueryEndDate": end_date,

"SummaryInterval": "FifteenMinutes",

"TimebarPersistence": True,

"DisplaySourceRIC": True

}

}

}

# Send the extraction request

response = requests.post(url, json=body, headers=headers)

print(f"Response received: {response}")


if response.status_code in [200, 202]:

if response.status_code == 202:

# Extraction is not immediately available, poll the status

location = response.headers.get("location")

return poll_extraction_status(token, location)

else:

# Extraction is ready

return response.json()["JobId"]

else:

print("Extraction request failed.")

print(f"Status Code: {response.status_code}")

print(f"Message: {response.text}")

return None

def poll_extraction_status(token, location_url):

headers = {

"Authorization": f"token {token}"

}

while True:

response = requests.get(location_url, headers=headers)

if response.status_code == 200:

# Extraction is ready

job_id = response.json()["JobId"]

print(f"Extraction completed. Job ID: {job_id}")

return job_id

elif response.status_code == 202:

# Extraction is still in progress

print("Extraction in progress. Waiting for 30 seconds...")

time.sleep(30)

else:

print("Error while polling extraction status.")

print(f"Status Code: {response.status_code}")

print(f"Message: {response.text}")

return None

# Request the extraction and get the Job ID

job_id = request_intraday_summaries(token, rics, start_date, end_date)


#technologydss-rest-apipython api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
86.3k 292 53 79

@aellis-bloor

Thank you for reaching out to us.

Please refer to the following articles:

You can check the extraction Notes for the extraction time.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.