Strikes
Get a list of available strike prices for an underlying symbol.
Making Requests
Use the strikes() method on the options resource to fetch strike prices. The method supports multiple output formats:
| Output Format | Return Type | Description |
|---|---|---|
| DATAFRAME | pandas.DataFrame or polars.DataFrame | Returns a DataFrame with strike prices (default). |
| INTERNAL | OptionsStrikes or OptionsStrikesHumanReadable | Returns an OptionsStrikes object. When use_human_readable=True, returns an OptionsStrikesHumanReadable object with capitalized field names. |
| JSON | dict | Returns the raw JSON response as a dictionary. |
| CSV | str | Writes CSV data to file and returns the filename string. |
strikes
def strikes(
symbol: str,
*,
expiration: str | datetime.datetime = None,
date: str | datetime.datetime = None,
output_format: OutputFormat = OutputFormat.DATAFRAME,
date_format: DateFormat = None,
columns: list[str] = None,
add_headers: bool = None,
use_human_readable: bool = False,
mode: Mode = None,
filename: str | Path = None,
) -> OptionsStrikes | OptionsStrikesHumanReadable | dict | str | MarketDataClientErrorResult
Fetches available strike prices for a given symbol. The symbol parameter can be passed as the first positional argument or as a keyword argument. All other parameters must be keyword-only.
Parameters
-
symbol(str)The underlying stock symbol for which to fetch strike prices.
-
expiration(str | datetime.datetime, optional)Filter by expiration date.
-
date(str | datetime.datetime, optional)Historical date for the strike prices.
-
output_format(OutputFormat, optional)The format of the returned data. Defaults to
OutputFormat.DATAFRAME. See Settings for details. -
date_format(DateFormat, optional)The date format to use in the response. Defaults to
DateFormat.UNIX. See Settings for details. -
columns(optional)Specify which columns to include in the response. See Settings for details.
-
add_headers(optional)Whether to include headers in the response. See Settings for details.
-
use_human_readable(optional)Whether to use human-readable format for values. Only applies when
output_format=OutputFormat.INTERNAL. See Settings for details. -
mode(Mode, optional)The data feed mode to use. See Settings for details.
-
filename(str | Path, optional)File path for CSV output (only used with
output_format=OutputFormat.CSV).
Returns
-
OptionsStrikes|OptionsStrikesHumanReadable|dict|str|MarketDataClientErrorResultThe strike prices in the requested format, or a
MarketDataClientErrorResultif an error occurred.
- Example (DataFrame)
- Example (Internal)
- Example (JSON)
- Example (CSV)
- Example (Human Readable)
from marketdata.client import MarketDataClient
client = MarketDataClient()
# Get options strikes as DataFrame (default)
# symbol can be passed positionally or as keyword
df = client.options.strikes("AAPL")
# or
df = client.options.strikes(symbol="AAPL")
print(df)
from marketdata.client import MarketDataClient
from marketdata.input_types.base import OutputFormat
client = MarketDataClient()
# Get options strikes as internal object
strikes = client.options.strikes("AAPL", output_format=OutputFormat.INTERNAL)
# Access strike prices
# Strikes are stored as dynamic fields based on expiration dates
# Access them via __dict__ or getattr
print(f"Updated: {strikes.updated}")
# Example: Access strikes for a specific expiration date
# The field names are expiration dates in format "YYYY-MM-DD"
for key, value in strikes.__dict__.items():
if key not in ["s", "updated"]:
print(f"{key}: {value}")
from marketdata.client import MarketDataClient
from marketdata.input_types.base import OutputFormat
client = MarketDataClient()
# Get options strikes as JSON
strikes = client.options.strikes("AAPL", output_format=OutputFormat.JSON)
print(strikes)
from marketdata.client import MarketDataClient
from marketdata.input_types.base import OutputFormat
from pathlib import Path
client = MarketDataClient()
# Get options strikes as CSV
csv_file = client.options.strikes(
"AAPL",
output_format=OutputFormat.CSV,
filename=Path("strikes.csv")
)
print(f"CSV file saved to: {csv_file}")
from marketdata.client import MarketDataClient
from marketdata.input_types.base import OutputFormat
client = MarketDataClient()
# Get options strikes in human-readable format
strikes = client.options.strikes(
"AAPL",
output_format=OutputFormat.INTERNAL,
use_human_readable=True
)
# Access strike prices and date
print(f"Date: {strikes.Date}")
# Strikes are stored as dynamic fields based on expiration dates
# Access them via getattr or __dict__
OptionsStrikes
@dataclass
class OptionsStrikes:
s: str
updated: datetime.datetime
# Dynamic fields: expiration dates as keys (e.g., "2024-01-20": list[float])
OptionsStrikes represents strike prices for options, with dynamic fields based on expiration dates. Each expiration date becomes a field containing a list of strike prices.
Properties
s(str): Status indicator ("ok" for successful responses).updated(datetime.datetime): The time when the data was last updated (automatically converted from timestamp).- Dynamic fields: Each expiration date (in format "YYYY-MM-DD") becomes a field containing a list of strike prices (list[float]).
Notes
- The
updatedfield is automatically converted to adatetime.datetimeobject from a Unix timestamp. - Strike prices are organized by expiration date, with each expiration date as a field name.
- Access strikes using
getattr()or__dict__(e.g.,getattr(strikes, "2024-01-20")).
OptionsStrikesHumanReadable
@dataclass
class OptionsStrikesHumanReadable:
Date: datetime.datetime
# Dynamic fields: expiration dates as keys (e.g., "2024-01-20": list[float])
OptionsStrikesHumanReadable represents strike prices in human-readable format with capitalized field names and formatted values.
Properties
Date(datetime.datetime): The time when the data was last updated (automatically converted from timestamp).- Dynamic fields: Each expiration date (in format "YYYY-MM-DD") becomes a field containing a list of strike prices (list[float]).
Notes
- The
Datefield is automatically converted to adatetime.datetimeobject from a Unix timestamp. - Strike prices are organized by expiration date, with each expiration date as a field name.
- Access strikes using
getattr()or__dict__(e.g.,getattr(strikes, "2024-01-20")). - Field names use capitalized format (e.g.,
Dateinstead ofupdated).