question

Upvotes
Accepted
37 0 0 2

How do retrieve distinct expiry dates of listed options on .SPX

Hi,

I am using refinitiv.data in Python. I need to retrieve the distinct expiry dates of the active listed options on .SPX. I think I need to find the distinct dates inside the request rather than outside, because there are so many listed options on .SPX I am likely to exceed the data cap if I retrieve all the non-distinct dates every time.

I have tried to do this via the group_by and group_count inputs to search.Definition(), i.e. search.Definition(... select='ExpiryDate', order_by='ExpiryDate', group_by='ExpiryDate', group_count=1 ...). However this attempt fails with the error "refinitiv.data._errors.RDError: Error code 400 | Invalid groupby: property 'ExpiryDate' does not support grouping". I am hoping there is another way. Thanks in advance.

Regards,
Jon

#technologysearchderivatives
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.

Thank you for participation in the forum, please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,
AHS

1 Answer

· Write an Answer
Upvote
Accepted
37 0 0 2

I experimented further and discovered ExpiryDateString, which is groupable. Using ExpiryDateString together with group_by and group_count, I can retrieve only the distinct expiry dates.

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.