New Options Backtester
Search, filter, and sort 65,771,713 backtests

Data API

Friday, December 8th 2023

Solving All Your Options Analysis Problems with the ORATS API — A Coding Blueprint

Read a quick overview of the advantages of the ORATS APIs and how to use them in Python.


This document discusses the use of the ORATS API for options analysis. It highlights the need for options data, the challenges in accessing comprehensive options data, and the advantages of using the ORATS API. It also provides comparisons with other options data providers and includes code snippets demonstrating the usage of the ORATS Data and Intraday Data APIs.

Article Index (use Ctrl-F to find sections)

  • Introduction: The need for options data
  • Usage: A difficult example of options analysis
  • Comparisons: Listing current options APIs
  • Examples: Quick code snippets for usage
  • Takeaways: Major advantages
  • Links

1. Introduction: The need for options data

Amongst All three trading styles (fundamental, technical, and sentimental analysis), data is the driving factor to almost all trading. This is especially true in the recent trend of newer algotrading services accessible to modern retail and institutional traders alike.

While there’s been a recent surge in popularity of stocks and a recent boom in relevant data based APIs, there aren’t many options APIs that can provide full coverage in both real-time and historical options data.

This disparity between the accessibility of stocks and options data (and APIs) is due to the drastically higher complexity that options data encompasses. For example, while a single stock at a single point in time may have one price, there can be 20+ options contracts, with 10+ strikes above or below the current price, for both contracts that are calls or puts. An example estimation below.

Note: This gets dramatically worse as most stocks data uses candlestick aggregates (open, high, low, close, volume) and options data uses Greeks (Delta, Gamma, Theta, Vega, and Rho), open interest, and implied volatility

AAPL Stock: 1 Stock = 1 data point

AAPL Options: 20 Expiration Dates* 20 Contracts (Strikes) * 2 (Calls and Puts) = ~800+ data points

Clearly the sheer amount of information required for options data is clear reason to why there aren’t many FinTech based companies who can provide full-coverage to options related data. Before we get to some code examples, the next section will give key examples to the power of using real-time and historical options data.

2. Usage: A difficult example of options analysis

In any kind of options strategy, buying or shorting naked or covered or long calls or puts, multi-leg strategies, etc., having real-time and historical chain data across all options, can drastically improve ones trading pipeline, whether you are algotrading or physically using a GUI (i.e. Think Or Swim, E-Trade).

While I can go into actual options strategies, the examples below will be concepts using data to aid the analysis of a current trader’s strategies.

  • Choosing options contracts based on a given strategy (single or multi-leg) on all existing contracts on the CBOE.
  • Based on the above, cross-matching those recommendations within a certain market sector and market cap with a certain P.E. ratio based on the underlying (specific stock).
  • From the above, finding which contracts have the highest open interest and implied volatility, also taking accounting for the spread of the contracts bid and ask as well as sizes.

This is difficult enough when using the current snapshot of real-time data. Imagine doing this across the entirety of options contracts beginning from 2007 to today (roughly 16 years).

The above three points are all very difficult to execute from most current options data services (APIs), and definitely would take a lifetime to perform if using a manual program clicking with a user interface. Many of the API services from the ORATS Company can enable this higher level of analysis. In the next section I’ll compare the API offerings from ORATS to other similar services.

3. Comparisons: Listing current options APIs

While most hedge funds have been using computerized or algorithmic trading since the 80’s, there are many FinTech companies giving this access to the average retail trader, even breathing new life to the current hedge-funds with newer innovations.

As mentioned in section 1 of this article, the sheer volume of options data makes it difficult for many FinTech companies to provide full coverage of options data as far back in time as possible. To have full coverage of options contracts, the data would have to provide the options quotes (bid, ask, sizes, quote, close) the Greeks (Delta, Gamma, Theta, Vega, Rho), as well as other features (volume, implied volatility, open interest, etc.).

As far as I know, ORATS is the only options data provider that can provide all three categories of these features, both in real-time (intraday data API) and any point in the past (Data API). Below I’ll list other options data providers with their caveats.

  • Yahoo Finance — Has full coverage of current options chain with all features, but lacks historical options chains that have expired. Also there is no official API (the yfinance python library is unofficial).
  • Barchart — Same as Yahoo Finance, but has an official API. Pricing is custom and API is probably rate limited.
  • NasdaqDataLink — Similar to Barchart, but doesn’t provide full coverage across all three categories of options features, and only supports quotes.
  • CBOE Data Shop —Better than the above. While there’s full-coverage of features, data is in bulk and payed per day, costing a whopping ~$947.69 per snapshot.
  • TD Ameritrade API — Same as Yahoo Finance with a free API, but real-time data requires difficult OAUTH implementation, also rate-limited to 120 calls per minute.

There are many more to list, but the main problem is all the above do not provide both real-time and historical data for options that have expired and are also rate-limited to the minute, or just cost way too much. ORATS is the only company with two APIs that can provide real-time and historical options data with large monthly request quotas rather than by the minute rate-limits, at reasonable prices.

4. Examples: Quick code snippets for usage

Below are some quick examples showing the use case for real-time and historical data using the ORATS Data and Intraday Data APIs (end of day, and intraday data respectively). These examples are only exploratory, do not use them for actual trading.

Using the below code requires an API Key and subscription to the relevant ORATS API product. Click here to view the APIs

  • Finding the max, min, and avg implied volatility on AAPL from the past 4260 trading days.

import requests, pandas as pd def get_iv(ticker): resp = requests.get("", params= { "ticker": ticker, "token": "{YOUR_ORATS_API_KEY}" } ) return pd.DataFrame(resp.json()["data"]) iv_history = get_iv("AAPL") max_iv = iv_history.iv.max() min_iv = iv_history.iv.min() avg_iv = iv_history.iv.mean()

  • Choosing specific AAPL contracts on the real-time option chain based on delta, open interest, and implied volatility

import requests, pandas as pd, time from io import StringIO def get_chain(ticker): resp = requests.get("", params= { "ticker": ticker, "token": "{YOUR_ORATS_API_KEY}" } ) options_chain = pd.read_csv(StringIO(resp.text)) return options_chain options_chain = get_chain("AAPL") options_chain = options_chain[ > 0.5] options_chain = options_chain[ options_chain.callOpenInterest > 1000] options_chain = options_chain[ options_chain.callMidIv > 1.0]

  • Using the TA RSI indicator to get a specific AAPL contract not overbought and not oversold over a given list of trading dates.

import requests, pandas as pd, time from io import StringIO def get_rsi(ticker, l_tradeDates, expirDate, strike, period=11): ''' 1. getting all chains from list of trade dates ''' options_chain = [] for tradeDate in l_tradeDates: resp = requests.get("", params= { "ticker": ticker, "token": "{YOUR_API_KEY}", "tradeDate": tradeDate # "202208081000" } ) temp = pd.read_csv(StringIO(resp.text)) options_chain.append(temp) ''' 2. Concating all options chains 3. Stripping target contracts by expirDate 4. Using talib to add a column with the RSI ''' options_chain = pd.concat(options_chain) options_chain = options_chain[options_chain.expirDate == expirDate] options_chain = options_chain[options_chain.strike == strike] options_chain[f"RSI_{period}"] = talib.RSI(options_chain["callBidPrice"], timeperiod=period ) return options_chain ''' 1. Obtaining RSI of contract from list of tradeDates ''' options_chain_rsi = get_rsi("AAPL", l_tradeDates = [ "202208081000", "202208081100", "202208081200", "202208081300", "2022080811400", "2022080811500", "2022080811600", "202208091000", "202208091100", "202208091200", "202208091300", "2022080911400", "2022080911500", "2022080911600", "202208101000", "202208101100", "202208101200", "202208101300", "2022081011400", "2022081011500", "2022081011600" ], expirDate = "2022-08-12", strike = 180, period = 10 ) ''' 2. Stripping contracts that are safe (not overbought or oversold) ''' options_chain_rsi = options_chain_rsi[ options_chain_rsi.RSI_10 <= 70] options_chain_rsi = options_chain_rsi[ options_chain_rsi.RSI_10 >= 30]

5. Takeaways: Major advantages

Clearly there is major power to the ability to access real-time and historical options data to aid in the analysis and implementation of various options trading strategies.

I very much recommend the ORATS Data and Intraday Data APIs as they provide full coverage to the entire options chain, with all features (greeks, etc.) at any point in time, from now to the past. Without these two APIs, the code examples in section 4 would not at all be possible.

Personally, I hope more companies follow in ORATS steps to provide higher coverage of data, both in feature size and historical data, so the community can further innovate in more technologies related to stocks, options and other equities.

6. Links

ORATS University
ORATS University
Master the art of options
Contact Us
Curious about enterprise pricing? Want to become an affiliate? Questions about our data? Let us know.
Your email
Your message
Institutional Quality Tools for All Options Traders
(312) 986 - 1060
36 Maplewood Ave, Portsmouth, NH 03801
Trading Tools
Historical Data
More Information