Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
0 1 4 7

How to get option chain of only options that were traded today?

Hi,

I use

ek.get_data('0#SPXW*.U', ['TRADE_DATE', 'ACVOL_1']) 

to get weekly option chain for SPX. It times out because it returns 13000+ items. Is there a way to get option chain of only options that were traded today.

streaming-data
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
32.2k 40 11 19

Hello @vlad.dimanshteyn,

I suggest for the best explanation of the Refinitiv Eikon content to engage with Refinitiv content experts directly, via Refinitiv Helpdesk Online -> Content -> Eikon.

My limited explanation, re your comment:

"/" in the instrument, "0#/SPXW*.U" is the delayed version of chain RIC "0#SPXW*.U". That is the instrument your Eikon user is permissioned for. The delay is set and differs per exchange and sector, a very common delay is 15 min, you can also check with the public listings of the delays, including Delayed Market Data Timing, or to confirm the delay for the specific instrument- Refintiiv content support are the experts who can help you the best.

Many of our APIs and libraries, including Eikon, if you do not have the permissions for the realtime instrument, and if there is an analogous delayed instrument, will switch you to the delayed instrument, seamlessly. However, in this case, the chain is still very large, and will still sometimes time out on the request.

What I have suggested, is the explicit workaround, that should allow you to proceed as of this time, as permissioned. And again, once Refinitiv Data library matures, there will likely be a more elegant approach available for this use case, but the specifics will depend on the API improvements. In my opinion, at a minimum, you should be able to do both of the steps, expand and request, with RD lib, without needing to use RDP lib for the fully reliable chain expansion.

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 so much Zoya, this is really helpful !!!!!! One last question. Once I'm permissioned for Eikon real time data, all this stuff will work real time (and I can take "/" out of rdp calls), is that correct? Thanks so much for your help !!!!!!!!!

Yes. And looking into the next steps, at some point, you will not have to use older RDP library to expand the heavy chains, and will be able to move to the solution that is fully with new RD library, cheers.

That's great !!! There will be StreamingChain function in RD then? How do I know when the new RD comes out and its capabilities? Is there a way to get notified when major release happens? Thans

I can not commit on the specifics, as RD lib does not precisely mimic RDP- many aspects are redesigned in order to improve.

Will try to give you a shout on the forums.

However, a good way to find out on your own is either to check periodically with Refinitiv Data on Pypi or to sign up for Refinitiv Developer Newsletter

Upvotes
32.2k 40 11 19

Hi @vlad.dimanshteyn ,

For questions on content, such as how to identify the content that you require, the best approach for a customer is to submit them directly to Refinitiv content support, via Refinitiv Helpdesk Online -> Content -> Eikon and your question will be assigned to the appropriate content expert.

This developers forum can be of most help to you with API usage questions, the moderators of the forum do not have the in-depth knowledge of the many types of content that is made available by Refinitiv.

From my looking, this chain is an OPRA .SPX option chain. You can test "0#SPX*.U" which is also an OPRA .SPX chain, results now in 7363 results, which is also a lot. You may wish to increase the timeout, as discussed in this previous discussion thread.

To get a definitive answer on the instruments/chains available, and per your requirement, please engage with content support directly and include all the details of the requirement for content. If you are not able to proceed as suggested- also let us know, and will give a hand by submitting on your behalf.


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 Zoya. I'm pulling "0#SPX*.U" also, that's a chain is monthly SPX options. Those do not time out. "0#SPXW*.U" is a chain of weekly SPX options and it times out when I pull it. Purely API question, not OPRA question. I would like to pull that chain somehow and I was thinking may be I can pull a subset at a time, may be the only ones that traded today.

option_chain, err = ek.get_data('0#SPXW*.U', ['TRADE_DATE', 'ACVOL_1'])

but only the ones where TRADE_DATE is today. That would cut the subset significantly and the request would not time out I believe. Is there a way to do it with your APIs? The reason I would like to have both is SPXW & SPX is because the more points the better when you construct the Vol Surface. In addition, I would like to thank you for some of the references you gave me about your Vol Surfaces, some good info in there. Really appreciate it.

EDAPI treats get_data request as atomic, you can not filter on request, making it smaller, you can review the available functionality via Eikon Data APIs for Python - Reference Guide.

From the design perspective, if this is something that you plan to run often, you may wish:

  • review Eikon Data API Usage and Limits Guideline and make sure your design will allow you to operate within the API usage limits
  • consider storing the instrument list on the first retrieval. Consequently, you can partition the list and submit the sub-lists as separate get_data requests. The aspects to review are how often the chain is updated and how tolerant are you to missing a change and running on the previously valid list

OPRA chains are notoriously large, so verifying with content experts the most suitable instrument(s) to use, directly, is what I would do.

Upvotes
32.2k 40 11 19

Hi @vlad.dimanshteyn ,

If you would like to request 0#SPXW*.U , every time, guaranteed, here is a little "divide and conquer" approach example that is not very elegant, but works, from my testing, consistently:

1. Expand the OPRA chain into constituents with RDP library:

import refinitiv.dataplatform as rdp
rdp.open_desktop_session(APP_KEY)  # your valid APP KEY
stream = rdp.StreamingChain(name="0#SPXW*.U")
stream.open()
constituents = stream.get_constituents()

2. Chunk the list and request the fields in chunks- this part can be done with RDP, RD or EK, I am including EK, as this is what you have been working with prior:

def list_to_chunks(long_list, chunk_size):
    chunked_list = list()
    for i in range(0, len(long_list), chunk_size):
        chunked_list.append(long_list[i:i+chunk_size])
    return chunked_list
#
import eikon as ek
ek.set_app_key(APP_KEY)  #you valid APP KEY
myRicChunks = list_to_chunks(constituents, 5000)
for i in range(len(myRicChunks)):
    print("Chunk #", i)
    option_chain, err = ek.get_data(myRicChunks[i], ['TRADE_DATE', 'ACVOL_1'])
    print(option_chain)
    print('Err=',err)

... as RD lib matures, it should allow for the best implementation for this requirement, as for many of the others it already does

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 so much Zoya, I will try it out. I need to get this chain, able to get SPX one and really need to get SPXW. If I can uses this for now, that is awesome !!!!

Hi Zoya,

I installed dataplatform using the following

pip install refinitiv-dataplatform

when I run the code you suggested as follows,


import refinitiv.dataplatform as rdp

rdp.open_desktop_session('d6835a6b13e44687be1496a6a779c66e4101aa77') stream = rdp.StreamingChain(name="0#SPXW*.U")

stream.open()

constituents = stream.get_constituents()


I get empty list [] for constituents, any idea?

1653326534350.png

Thanks so much, Vlad

1653326534350.png (11.3 KiB)
Hi @vlad.dimanshteyn,

Works on my side, takes long. Just re-tested twice in CodeBook.

Are you testing in CodeBook? If not, please test in CodeBook - let us know how this works on your side. Depending on the results, this should help to narrow down the possible causes.

I'm not using Codebook. I'm just using Spyder, the same way I was doing ek coding. Not sure how to use Codebook. I will try and let you know. Thanks you

Not sure if I'm doing this right but I opened new Console and then executed one line at a time with "Run Cell", This is what I get, I can not see any variables


1653329071225.png

1653329071225.png (82.2 KiB)
Upvotes
32.2k 40 11 19

Hi @vlad.dimanshteyn ,

The test with CodeBook console should work. You can either print constituents, or the quickest is just printing their length.

I test in CodeBook with Python Notebook, as that allows to test one by one, the sections of the book, but this is just a convenience:

shot.gif

I see 13106 at this time. Let me know


shot.gif (98.9 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.

Getting 0 here as well

1653330292471.png

1653330292471.png (43.8 KiB)
Getting 0 for number of constituents
Upvotes
0 1 4 7

Just ran the whole thing

1653330398967.png


1653330398967.png (16.0 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.

Upvotes
32.2k 40 11 19

Hi @vlad.dimanshteyn

As a sanity check only, the exact same code in CodeBook with name="0#SPX*.U" works for you and returns 6490 constituents after a wait?

And with invalid instrument name="FAKERIC" comes back very quickly and returns 0 ( because the stream will be opened, even if the instrument is invalid or you are not entitled), but returned constituents will be empty?

If that is the case, as the code is the same as works for me, in Codebook (same libraries and same versions) and you are failing on your side for this chain, I would suggest to open a support case with Refinitiv helpdesk, to verify that you are permissioned for this instrument.

I did not think so from your initial question, as you have mentioned a timeout, that I have seen as well on my side, from time to time.

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.

SPXW works for me sometimes doing it the other way (not streaming), most of the time it times out. So you are right, I do not believe its permission issue with SPXW. I will try to run SPX with your code right now and let you know. SPX works consistently the other way.

Just tried to get SPX chain (works fine the other way) and getting 0 back. It seems to be streaming issues. Any ideas what I should check for?


1653333531958.png


1653333531958.png (16.1 KiB)
Comes back very quickly in both cases
SPX work for me if I just Use get_data (without streaming) using ek library & SPXW times out.

The streaming with rd workd fine, sreaming with rdp does not. Is there something similar in rd?

1653337425027.png

1653337425027.png (33.8 KiB)
Show more comments
Upvotes
32.2k 40 11 19

Hello @vlad.dimanshteyn ,

Try replacing in streaming code

import refinitiv.dataplatform as rdp
rdp.open_desktop_session(APP_KEY)  # your valid APP KEY
stream = rdp.StreamingChain(name="0#/SPXW*.U")
stream.open()
constituents = stream.get_constituents()
len(constituents)

This should allow you to retrieve chain constituents as delayed, which for the purpose of identifying the constituents should not make any difference, in my understanding.

In addition, with my chunking code, go 2k step:

def list_to_chunks(long_list, chunk_size):
    chunked_list = list()
    for i in range(0, len(long_list), chunk_size):
        chunked_list.append(long_list[i:i+chunk_size])
    return chunked_list
#
import eikon as ek
ek.set_app_key(APP_KEY)  #you valid APP KEY
myRicChunks = list_to_chunks(constituents, 2000)
for i in range(len(myRicChunks)):
    print("Chunk #", i)
    option_chain, err = ek.get_data(myRicChunks[i], ['TRADE_DATE', 'ACVOL_1'])
    print(option_chain)
    print('Err=',err)

Let us know how this works on your side.


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.

Thats Zoya. I'll try it first thing tomorrow morning & let you know.

I had to implement my own version of chunking code what I did SPX ek.get_data(). Thanks so much, will let you know

That worked Zoya, thanks so much !!!!

Can you please explain to me "/" you put in front of SPXW, I did not have to put any slashes when I used ek.get_data(). The reason its important is because we are going to get real time data shortly, out data person told me that I need Web Sockets to get real time? Is that true? How is that going to effect this code? Thanks so much !!!!!

Upvotes
0 1 4 7

Thank you Zoya, you helped me out big time !!!!!!!!!!!!!!!!!!!!

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.