Hi, I'm following the TRTH_OnDemand_IntradayBars Python example (available under https://developers.refinitiv.com/thomson-reuters-tick-history-trth/thomson-reuters-tick-history-trth-rest-api/downloads) to get HistoricalReferenceExtractionRequest (instead of TickHistoryIntradaySummariesExtractionRequest).
My template looks something like this:
{
"ExtractionRequest": {
"@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.HistoricalReferenceExtractionRequest",
"ContentFieldNames": [
"RIC",
"Exchange Code",
"Security Description",
"Currency Code",
"Expiration Date",
"RIC Root",
"Trading Status",
"Underlying RIC",
"Put Call Flag",
"Start date",
"Thomson Reuters Classification Scheme"
],
"IdentifierList": {
"@odata.type": "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
"InstrumentIdentifiers": [{
"Identifier": "0#NIY:",
"IdentifierType": "ChainRIC"
},
{
"Identifier": "0#RTY:",
"IdentifierType": "ChainRIC"
}],
"ValidationOptions": { "AllowHistoricalInstruments": true},
"UseUserPreferencesForValidationOptions": false
},
"Condition": {
"StartDate": "__QUERY_START_TIME_",
"EndDate": "__QUERY_END_TIME_"
}
}
}
Everything looks good, except for when requesting a small universe (like in the template above).
The example assumes that there's always a 202 status code (extraction not finished - must wait) before a 200 code (extraction completed), but this is not always the case with a small universe. As a result, the code fails on the step #3 due to "r3" variable not defined.
#As long as the status of the request is 202, the extraction is not finished;
#we must wait, and poll the status until it is no longer 202:
while (status_code == 202):
print ('As we received a 202, we wait 30 seconds, then poll again (until we receive a 200)')
time.sleep(30)
r3 = requests.get(requestUrl,headers=requestHeaders)
status_code = r3.status_code
print ('HTTP status of the response: ' + str(status_code))
#When the status of the request is 200 the extraction is complete;
#we retrieve and display the jobId and the extraction notes (it is recommended to analyse their content)):
if status_code == 200 :
r3Json = json.loads(r3.text.encode('ascii', 'ignore'))
jobId = r3Json["JobId"]
print ('\njobId: ' + jobId + '\n')
notes = r3Json["Notes"]
print ('Extraction notes:\n' + notes[0])
I have not been able to find a workaround for this (other than requesting more instruments that I don't need, which is definitely not ideal). I tried defining "r3", but no luck to get the JobId.
Appreciate your help!
Thanks,
Luz