> For the complete documentation index, see [llms.txt](https://docs.openalgo.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openalgo.in/api-documentation/v1/data-api/option-chain.md).

# Option Chain

Get the complete option chain for a given underlying and expiry, including quotes for all strikes.

## Endpoint URL

```http
Local Host   :  POST http://127.0.0.1:5000/api/v1/optionchain
Ngrok Domain :  POST https://<your-ngrok-domain>.ngrok-free.app/api/v1/optionchain
Custom Domain:  POST https://<your-custom-domain>/api/v1/optionchain
```

## Sample API Request

```json
{
  "apikey": "<your_app_apikey>",
  "underlying": "NIFTY",
  "exchange": "NSE_INDEX",
  "expiry_date": "30DEC25",
  "strike_count": 10
}
```

## Sample cURL Request

```bash
curl -X POST http://127.0.0.1:5000/api/v1/optionchain \
  -H 'Content-Type: application/json' \
  -d '{
  "apikey": "<your_app_apikey>",
  "underlying": "NIFTY",
  "exchange": "NSE_INDEX",
  "expiry_date": "30DEC25",
  "strike_count": 10
}'
```

## Sample API Response

```json
{
  "status": "success",
  "underlying": "NIFTY",
  "underlying_symbol": "NIFTY",
  "underlying_exchange": "NSE_INDEX",
  "underlying_ltp": 26215.55,
  "underlying_prev_close": 26150.3,
  "expiry_date": "30DEC25",
  "expiry_ts": 1767087000,
  "server_ts": 1766115900,
  "atm_strike": 26200.0,
  "quotes_included": true,
  "greeks_included": false,
  "forward_price": null,
  "chain": [
    {
      "strike": 26100.0,
      "ce": {
        "symbol": "NIFTY30DEC2526100CE",
        "label": "ITM2",
        "ltp": 490,
        "bid": 490,
        "ask": 491,
        "bid_qty": 375,
        "ask_qty": 150,
        "open": 540,
        "high": 571,
        "low": 444.75,
        "prev_close": 496.8,
        "volume": 1195800,
        "oi": 0,
        "lotsize": 65,
        "tick_size": 0.05
      },
      "pe": {
        "symbol": "NIFTY30DEC2526100PE",
        "label": "OTM2",
        "ltp": 193,
        "bid": 191.2,
        "ask": 193,
        "open": 204.1,
        "high": 229.95,
        "low": 175.6,
        "prev_close": 215.95,
        "volume": 1832700,
        "oi": 0,
        "lotsize": 65,
        "tick_size": 0.05
      }
    },
    {
      "strike": 26200.0,
      "ce": {
        "symbol": "NIFTY30DEC2526200CE",
        "label": "ATM",
        "ltp": 427,
        "bid": 425.05,
        "ask": 427,
        "open": 449.95,
        "high": 503.5,
        "low": 384,
        "prev_close": 433.2,
        "volume": 2994000,
        "oi": 0,
        "lotsize": 65,
        "tick_size": 0.05
      },
      "pe": {
        "symbol": "NIFTY30DEC2526200PE",
        "label": "ATM",
        "ltp": 227.4,
        "bid": 227.35,
        "ask": 228.5,
        "open": 251.9,
        "high": 269.15,
        "low": 205.95,
        "prev_close": 251.9,
        "volume": 3745350,
        "oi": 0,
        "lotsize": 65,
        "tick_size": 0.05
      }
    },
    {
      "strike": 26300.0,
      "ce": {
        "symbol": "NIFTY30DEC2526300CE",
        "label": "OTM2",
        "ltp": 367.55,
        "bid": 364,
        "ask": 367.55,
        "open": 378,
        "high": 437.4,
        "low": 327.25,
        "prev_close": 371.45,
        "volume": 2416350,
        "oi": 0,
        "lotsize": 65,
        "tick_size": 0.05
      },
      "pe": {
        "symbol": "NIFTY30DEC2526300PE",
        "label": "ITM2",
        "ltp": 266,
        "bid": 264.2,
        "ask": 266.5,
        "open": 263.1,
        "high": 311.55,
        "low": 240,
        "prev_close": 289.85,
        "volume": 2891100,
        "oi": 0,
        "lotsize": 65,
        "tick_size": 0.05
      }
    }
  ]
}
```

## Request Body

| Parameter      | Description                                                                                                                                        | Mandatory/Optional | Default Value |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------- |
| apikey         | Your OpenAlgo API key                                                                                                                              | Mandatory          | -             |
| underlying     | Underlying symbol (NIFTY, BANKNIFTY, SENSEX)                                                                                                       | Mandatory          | -             |
| exchange       | Underlying exchange. Any value in the shared `VALID_EXCHANGES` list                                                                                | Mandatory          | -             |
| expiry\_date   | Expiry date in DDMMMYY format                                                                                                                      | Mandatory          | -             |
| strike\_count  | Number of strikes above and below ATM, 1 to 100, or `null`                                                                                         | Optional           | All strikes   |
| with\_greeks   | When `true`, attaches `implied_volatility`, `delta`, `gamma`, `theta`, and `vega` to every CE and PE leg, computed from the quotes already fetched | Optional           | `false`       |
| interest\_rate | Annualized risk-free rate as a percentage, 0 to 100. Used only when `with_greeks` is `true`                                                        | Optional           | `0`           |

These seven fields are the complete `OptionChainSchema`. Any other field returns HTTP 400.

Broker adapters may use an optimized option-chain call; otherwise the service resolves contracts locally and retrieves quotes through the normalized market-data layer.

## Response Fields

| Field                   | Type    | Description                                                                                                                  |
| ----------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| status                  | string  | "success" or "error"                                                                                                         |
| underlying              | string  | Underlying base symbol                                                                                                       |
| underlying\_symbol      | string  | The exact symbol whose quote was used as the reference price                                                                 |
| underlying\_exchange    | string  | The exchange that reference quote came from                                                                                  |
| underlying\_ltp         | number  | Current underlying price                                                                                                     |
| underlying\_prev\_close | number  | Underlying previous close                                                                                                    |
| expiry\_date            | string  | Expiry date in DDMMMYY format                                                                                                |
| expiry\_ts              | number  | Exact expiry instant as a Unix epoch value in seconds, or `null` if it could not be derived                                  |
| server\_ts              | number  | Server time as a Unix epoch value in seconds, so a client can correct for its own clock skew before computing time to expiry |
| atm\_strike             | number  | At-the-money strike price                                                                                                    |
| quotes\_included        | boolean | Whether live quotes were attached to the legs                                                                                |
| greeks\_included        | boolean | Whether Greeks were attached, that is `with_greeks` was true and quotes were available                                       |
| forward\_price          | number  | Forward price used for the Greeks, or `null` when Greeks were not computed                                                   |
| chain                   | array   | Array of strike data                                                                                                         |

### Chain Array Fields

| Field  | Type   | Description                                                           |
| ------ | ------ | --------------------------------------------------------------------- |
| strike | number | Strike price                                                          |
| ce     | object | Call option data, or `null` when no CE contract exists at that strike |
| pe     | object | Put option data, or `null` when no PE contract exists at that strike  |

### Option Data Fields

| Field               | Type   | Description                       |
| ------------------- | ------ | --------------------------------- |
| symbol              | string | Option symbol                     |
| label               | string | ATM, ITM1, ITM2..., OTM1, OTM2... |
| ltp                 | number | Last traded price                 |
| bid                 | number | Best bid price                    |
| ask                 | number | Best ask price                    |
| bid\_qty            | number | Quantity at the best bid          |
| ask\_qty            | number | Quantity at the best ask          |
| open                | number | Day's open                        |
| high                | number | Day's high                        |
| low                 | number | Day's low                         |
| prev\_close         | number | Previous close                    |
| volume              | number | Trading volume                    |
| oi                  | number | Open interest                     |
| lotsize             | number | Lot size                          |
| tick\_size          | number | Tick size                         |
| implied\_volatility | number | Only when `with_greeks` is true   |
| delta               | number | Only when `with_greeks` is true   |
| gamma               | number | Only when `with_greeks` is true   |
| theta               | number | Only when `with_greeks` is true   |
| vega                | number | Only when `with_greeks` is true   |

There is no `rho` on chain legs. Use [Option Greeks](/api-documentation/v1/data-api/optiongreeks.md) for a single contract when you need it.

## Notes

* Without **strike\_count**, returns the **entire option chain** for the expiry
* The **label** field indicates whether the option is ATM, ITM, or OTM
* For CE options: strikes below ATM are ITM, above are OTM
* For PE options: strikes above ATM are ITM, below are OTM
* Use this for **options analysis** and **strategy selection**
* Greeks are skipped, and `greeks_included` comes back `false`, when the expiry instant cannot be derived or the chain has already expired

## Use Cases

* **Option analysis**: View premiums across strikes
* **Strategy selection**: Find suitable strikes for spreads/strangles
* **Volatility analysis**: Compare premiums at different strikes

***

**Back to**: [API Documentation](/api-documentation/v1.md)
