question

Upvotes
Accepted
23 0 1 4

Error in retrieving tick history TRTH in python

I have followed the instruction given in the following link to pull the the tick data and it is given me the below mentioned error.


Link: https://developers.refinitiv.com/article/tick-history-article-5


ProxyError: HTTPSConnectionPool(host='hosted.datascopeapi.reuters.com', port=443): Max retries exceeded with url: /RestApi/v1/Users/Users(9015265) (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0000020A5136C048>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)))


please help me how to fix it. I have run the code only once and that too at the start of the day.

tick-history-rest-api
icon clock
10 |1500

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

Upvotes
Accepted
13k 32 12 18

Hello @varun.divakar, The error message implies that the python application is unable to reach the TRTH server. This could be because of a number of reasons like your firewall blocking the outgoing connections or a network proxy server.

First step would be to see if you are able to connect to server - https://hosted.datascopeapi.reuters.com in a web browser. If so, then copy the proxy information from your web browser and use it in the sample code. For e.g: if your proxy server is myproxy on port 9999, then use:


r1 = requests.get(requestUrl, headers = requestHeaders, proxies = {"https": "https://myproxy:9999"}) 


If there is no proxy in your network and you have a direct connection to internet, then omit the proxy parameter:

r1 = requests.get(requestUrl, headers = requestHeaders) 
icon clock
10 |1500

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

Upvotes
23 0 1 4

Hi Gurpreet,

Thank you for the response. I have tried to open the link (https://hosted.datascopeapi.reuters.com) you mentioned. But I am unable to do so. I have attached the screenshot of the site that is opening instead. Let me know how I can resolve this, Thank you.



1585229469486.png (505.0 KiB)
icon clock
10 |1500

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

Upvotes
13k 32 12 18

All we wanted to check is that you have a network route to the DSS/TRTH servers - which you do. Now you should copy the proxy information from your browser into the python sample. If there is no proxy, omit the proxy parameter in the API call.

icon clock
10 |1500

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

Upvotes
23 0 1 4

I removed the proxy and tried and it worked. Thank you for your help. Now, I am trying the next part of the document where we fetch the contracts for a ticker, and encountered a new error.

Error:

{'error': {'message': "Malformed request payload: '@odata.type' is either missing or misplaced for type ThomsonReuters.Dss.Api.Search.DateComparison"}}

The code I used is a below:

requestUrl = 'https://hosted.datascopeapi.reuters.com/RestApi/v1/Search/FuturesAndOptionsSearch'


requestHeaders = {

'Prefer':'respond-async;odata.maxpagesize=5000',

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

'Authorization': 'token ' + token

}


requestBody = {

'SearchRequest': {

'@odata.context': 'http://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#ThomsonReuters.Dss.Api.Search.FuturesAndOptionsSearchRequest',

'FuturesAndOptionsType': 'Futures',

'UnderlyingRic': 'SB',

'ExpirationDate': {

'@odata.type': '#ThomsonReuters.Dss.Api.Search.DateValueComparison',

'ComparisonOperator': 'GreaterThanEquals',

'Value': str(dt.date.today())

}

}

}


r2 = requests.post(requestUrl, json = requestBody, headers = requestHeaders)

r2Json = json.loads(r2.text)

icon clock
10 |1500

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

Upvotes
13k 32 12 18

Its advisable to start a new question for a new issue - this helps us track the question status.

There must be an error in your code, it is working an returning blank result for me:

{
	'@odata.context': 'https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#Collection(ThomsonReuters.Dss.Api.Search.FuturesAndOptionsSearchResult)',
	'value': []
}


icon clock
10 |1500

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

Click below to post an Idea Post Idea