question

Upvotes
Accepted
83 1 1 2

how to retrieve the list of live option contracts for a given equity or equity index.

Hello,

I'm looking for a code sample, using Refinitiv Data Platform APIs, preferably in python, that would show how to retrieve the list of live option contracts for a given equity or equity index.

I have seen the great article on search (https://developers.refinitiv.com/en/article-catalog/article/building-search-into-your-application-workflow) but wondering if a code snippet illustrating the above question exists.


Many thanks.

Samuel

rdp-apirefinitiv-data-platformsearchderivatives
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.

Posts without any customer identifying information should be public. Changing the visibility of this question.

@samuel.schwalm

Thank you for your participation in the forum. Are any of the replies below satisfactory in resolving your query? If yes please click the 'Accept' text next to the reply that best answers your question. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

-AHS

@samuel.schwalm

Hi,

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

AHS

Upvotes
Accepted
17.3k 82 39 63

Hi @leszek.lubecki,

Yes, the more we look at the results, the more we will filter - search will always be iterative :-).

Good point about the date check - when applying the expiryDate filter, this resulted in ~100 fewer hits for the '.VIX' symbol. Regarding the inability of the UnderlyingQuoteRIC not being able to support the exact match capability, you can always apply a little trickery to force exact matching, i.e.

                
  1. ric = "'.VIX'"
  2. rdp.search(
  3.     view = rdp.SearchViews.EquityDerivativeQuotes,
  4.     filter = "AssetState eq 'AC' and \
  5.               startswith(UnderlyingQuoteRIC, " + ric + ") and \
  6.               endswith(UnderlyingQuoteRIC," + ric + ") and \
  7.               RCSAssetClass eq 'OPT' and IsChain eq false and \
  8.               ExpiryDate ge " + dt.datetime.today().strftime('%Y-%m-%d'),
  9.     select = "DocumentTitle, RIC, ExpiryDate, CallPutOption, StrikePrice",
  10.     top = 10000
  11. )

It may not be as clean but should help avoid getting hits for things like 'AAPL.OQ'

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.

Many thanks. work fine for me.

Upvotes
3.8k 4 4 6

Hi @samuel.schwalm

I see that field UnderlyingNDAQuoteRICcontains information about underlying instrument but is not "searchable". Here is what I was able to get using PermID of an instrument

permid = rdp.convert_symbols(
    symbols = ['IBM'], 
    to_symbol_types = [rdp.SymbolTypes.OAPermID] )

rdp.search(view = rdp.SearchViews.EquityDerivativeQuotes,
    filter = "AssetState eq 'AC' and UnderlyingIssuerOAPermID eq '" + permid['IssuerOAPermID'][0] + "'  and DerivedCategory eq 'OPTION'",
    select = 'RIC',
    top=10000
)


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.

Thanks a lot @marcin.bunkowski, Can you share the samples as may not have the right rdp lib instantiated.


cheers

Samuel

Upvotes
17.3k 82 39 63

Hi @samuel.schwalm,

Try this:

rdp.search(
    view = rdp.SearchViews.EquityDerivativeQuotes,
    filter = "AssetState eq 'AC' and UnderlyingQuoteRIC eq 'IBM' and \
              RCSAssetClass eq 'OPT' and IsChain eq false",
    select = "DocumentTitle, RIC, ExpiryDate, CallPutOption, StrikePrice",
    top = 10000
)

I don't know what you were expecting back in terms of rows, but we could possibly narrow down the result set if you see some items in the list that shouldn't be there. For example, the last one in the screenshot below may be something that you want to ignore.


1611166509628.png (140.8 KiB)
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.

@nick.zincone.1 I think that your solution is more convenient. When I did try UnderlyingQuoteRIC as well but without an additional filter on RCSAssetClass you get plenty not relevant RIC codes. I did try on "VOD.L".

Upvotes
18 0 1 4

@nick.zincone.1 @samuel.schwalm

Hey,

Given how the search is structure I think using the expiry date for filtering might be a good way to go to exclude non-viable RICs (or drop anything from the dataframe that doesn't have one)


rdp.search(
    view = rdp.SearchViews.EquityDerivativeQuotes,
    filter = "AssetState eq 'AC' and UnderlyingQuoteRIC eq 'IBM' and \
              RCSAssetClass eq 'OPT' and IsChain eq false and \
              ExpiryDate ge " + date.today().strftime('%Y-%m-%d'),
    select = "DocumentTitle, RIC, ExpiryDate, CallPutOption, StrikePrice",
    top = 10000
)



On the "live" part; in my experience it's best to use the ExpiryDate to filter for live options, I've seen on occasion a delay between an option contract expiring and being removed from the real time feeds, and actually being tagged as inactive and being removed from search like here for the first couple here (expired yesterday, no longer retrievable but still in search):


Something to be aware of re UnderlyingQuoteRIC as criterion. It uses an exact match to produce results. I.e. you need the specific listing that the options are listed for. Especially for US options this might prove a problem from a user perspective, as they may be looking at specific exchange listing like NYSE (IBM.N), or Nasdaq (AAPL.OQ) whereas the options themselves have the consolidated listings as underlyings (IBM, AAPL.O). So possibly the approach @marcin.bunkowski suggested might be valid.


1611221700307.png (36.2 KiB)
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.