How to query eod options

Overview

In this how to guide, we will show you how simple it is to use Intrinio to efficiently query our End of Day Historical Options data. In this example we will be using Python however, you can use any one of our client SDKs or query our REST API directly using your programming language of choice.


Prerequisites

  1. Create an account to get an API key
  2. Contact sales@intrinio.com to sign up for a free trial
  3. Choose which SDK you wish to use Python, Javascript/Node, C#, Java, Ruby, or R.

Procedure

Install the Intrinio Python SDK if you haven't already.

pip install intrinio-sdk

Using the Option Prices EOD we can get the daily open, high, low, close, closing ask, closing bid, open interest, greeks, implied volatility and more for a options contract. Create new python file and add the following code updating your api key.

import intrinio_sdk as intrinio

intrinio.ApiClient().set_api_key('YOUR_API_KEY_HERE')

identifier = 'AAPL231013C00180000'

response = intrinio.OptionsApi().get_options_prices_eod(identifier)

print(response)

Running the code above, you'll receive the daily end of day data for a single contact! That was easy... and like many of our endpoints that contain historical data, you can page through the history which is great for backfilling. The obvious problem is that are over a million contracts. That's a lot of api calls! The Option Chain EOD endpoint will enable you pull all the contracts for a specific expiration date and ticker.

import intrinio_sdk as intrinio

intrinio.ApiClient().set_api_key('YOUR_API_KEY_HERE')

symbol = 'AAPL'
expiration = '2023-10-13'

response = intrinio.OptionsApi().get_options_chain_eod(symbol, expiration)
print(response)

Ok, that is a little more useful but how can I programmatically discover which expiration dates are available? I'm glad I asked myself because we have an endpoint for you (and myself).

import intrinio_sdk as intrinio

intrinio.ApiClient().set_api_key('YOUR_API_KEY_HERE')

symbol = 'AAPL'
after = '2023-01-01'
before = '' # Leave an empty string to not specify

response = intrinio.OptionsApi().get_options_expirations_eod(symbol, after=after, before=before)
print(response)

Alright, I can see how that would be useful. Let's tie that together with the chain endpoint but let's do it for a specific date.

import intrinio_sdk as intrinio

intrinio.ApiClient().set_api_key('YOUR_API_KEY_HERE')

symbol = 'AAPL'
after = '2023-10-01'
before = '' # Leave an empty string to not specify

date = '2023-10-02' # The date to retrieve eod prices for

response = intrinio.OptionsApi().get_options_expirations_eod(symbol, after=after, before=before)
print(response)

for expiration in response.expirations:
    chain_response = intrinio.OptionsApi().get_options_chain_eod(symbol, expiration, date=date)
    print(chain_response)

This is fine for testing small scale exploration as well as pulling down data one day at a time but I know what you are thinking. You're thinking "this is a massive dataset and I want all of it in a flat file". We've got you covered. We can do csv file delivery as well; in fact we encourage it for backfilling historical data. Request a consultation and we will start you with a trial or sample file.

Conclusion

We strive to make data ingestion as simple as possible so you can focus on building your market beating application.

Questions? Comments? Ready to buy? Contact sales@intrinio.com.