For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
5 0 0 3

Searched for Futures and Options unsuccessfully with status code 502 in between of multiple long runs

DSS Rest API

Domain - https://selectapi.datascope.refinitiv.com/RestApi/v1/

URL - https://selectapi.datascope.refinitiv.com/RestApi/v1/Search/FuturesAndOptionsSearch

Total instruments for 1 day data - 418788

Details of issue -
As more then 400 instruments were giving server busy error, tried querying this above URL in chunks with instruments = 400 and 'respond-async;odata.maxpagesize=1000'.


After running for 5 loops(instrument chunks), it failed and raised error -

Processing instruments bucket No.5 for searchFuturesOptions with len:400 Instrument Range BLSR.TA<-->RKH.L

ERROR Searched for Futures and Options unsuccessfully with status code 502


msg: 'Content of request: b\'{"error":{"message":"An error occurred on the server. If this problem persists, contact Support (referenci' (str)

response: '<Response [502]>' (Response)


Could you please guide what is the good way to query large amount of instruments, as if its fails in between, time and processing both gets wasted.

#technologydss-rest-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.

Upvotes
Accepted
83.1k 281 53 77

@trisha.gehlot

Thank you for reaching out to us.

According to the DSS Status Codes page, the 502 is Bad Gateway.

502 Bad Gateway indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request. The application can retry.

What do you mean by "Total instruments for 1 day data - 418788"?

Please share the request message that you are using. I will try it on my machine.


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.

Upvotes
5 0 0 3

@Jirapongse Thank you for your response!!


As it was a Bad Gateway, it might not arise again, but could please suggest best way to deal with large amount of instruments.

418788 this is the total number of instruments to be searched.

Request body-

searchRequest = {"IdentifierType": identifierType, "PreferredIdentifierType": preferredIdentifierType}

if underlyingRIC:

searchRequest["UnderlyingRic"] = identifiers

requestBody = json.dumps({"SearchRequest": searchRequest})

return requestBody

Request Body -

{"SearchRequest": {"IdentifierType": "Ric", "PreferredId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O.A,.RUI,.RUT,ALL.N,MLM.N,HBAN.O,MXIM.O,VLY.O,ENIA.N,JJSF.O,MCHP.O,NWN.N,REGN.O,MEOH.O,TEVA.N,PZZA.O,ADTN.O,GBX.N,COF.N,STRT.O,HIW.N,LMT.N,DRI.N,AFG.N,INCY.O,BWA.N,RHHBY.PK,FCX.N,AKS.N,TGS.N,UL.N,CPSS.O,AEG.N,SWM.N,IT.N,ITT.N,HIG.N,TUP.N,DOFSQ.PK,FMS.N,ATGE.N,CBRI.PK,AGLJ.J,SASY.PA,TDC.CO,ALSO.PA,CNPP.PA,PUBP.PA,AGFB.BR,SAN.MC,WHLJ.J,ADEN.S,ITUJ.J,ABBN.S,NELES.HE,IDR.MC,HSBA.L,INCH.L,NTGY.MC,HUDN.AS,LKOH.MM,MSNG.MM,RTKM_p.MM,ALB.MC,BMPS.MI,OML.L,TEF.MC,RTKM.MM,ABB.ST,SAF.PA"}}'


response = requests.post(

DataScopeURL.SEARCH_FUTURES_OPTIONS,

requestBody,

headers=populateHttpRequestHeaders(self.loginDetails, self.proxyServers, prefer='respond-async;odata.maxpagesize=1000', passToken=True),

proxies=self.proxyServers,

)

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.

@trisha.gehlot

I found the answer in this discussion.

Upvotes
5 0 0 3

@Jirapongse Thank you for this paging logic, will try to increase page size!!

But the issue above is, when I send 418788 instruments all together, the server give exception.

And when I sent instrument Chunks for eg. 2000 instruments is taking 12 hours in querying this Rest API

I need to check, what is the best practice to deal with this, while sending the query to FuturesAndOptionsSearch


*Also if you can confirm, how many concurrent queries they support for our account?

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.

@trisha.gehlot

I think 418788 instruments are too much for search endpoint.

Please contact your LSEG account team or sales team directly to verify this use case.

We may be able to suggest other products for this use case.

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.