Examples and tutorials
Options
Equity options: Introduction
Options on futures: Introduction
All options with a given underlying
Join options with underlying prices
US equity options volume by venue
Resample US equity options NBBO
Estimate implied volatility
Get symbols for 0DTE options
Daily statistics for equity options
Get end of day option spreads
Historical data
Programmatic batch downloads
Best bid, best offer, and midprice
Custom OHLCV bars from trades
Join schemas on instrument ID
Plot a candlestick chart
Calculate VWAP and RSI
End-of-day pricing and portfolio valuation
Benchmark portfolio performance
Market halts, volatility interrupts, and price bands
Resample OHLCV from 1-minute to 5-minute
Convert DBN to other encoding formats
Request a large number of symbols
Algorithmic trading
A high-frequency liquidity-taking strategy
Build prediction models with machine learning
Execution slippage and markouts
Matching engine latencies
Using messaging rates as a proxy for implied volatility
Mean reversion and portfolio optimization
Pairs trading based on cointegration
Build a real-time stock screener
Core concepts
Venues and datasets
Cboe BYX Depth
Cboe BZX Depth
Cboe EDGA Depth
Cboe EDGX Depth
CFE
CME Globex MDP 3.0
Databento US Equities Mini
Databento US Equities Summary
Eurex
European Energy Exchange
ICE Endex
ICE Europe Commodities
ICE Europe Financials
ICE Futures US
IEX TOPS
MEMX Memoir Depth
MIAX Pearl Depth of Market
Nasdaq Basic with NLS Plus
Nasdaq TotalView-ITCH
Nasdaq BX TotalView-ITCH
Nasdaq PSX TotalView-ITCH
NYSE Integrated
NYSE American Integrated
NYSE Arca Integrated
NYSE National Trades and BBO
NYSE Texas Integrated
OPRA
Adjustment factors
Corporate actions
Security master
API Reference
Resources
Release notes
C++
0.51.0 - 2026-03-17
0.50.0 - 2026-03-03
0.49.0 - 2026-02-24
0.48.0 - 2026-02-18
0.47.0 - 2026-02-04
0.46.1 - 2026-01-27
0.46.0 - 2026-01-20
0.45.0 - 2025-12-10
0.44.0 - 2025-11-18
0.43.0 - 2025-10-22
0.42.0 - 2025-08-19
0.41.0 - 2025-08-12
0.40.0 - 2025-07-29
0.39.1 - 2025-07-22
0.39.0 - 2025-07-15
0.38.2 - 2025-07-01
0.38.1 - 2025-06-25
0.38.0 - 2025-06-10
0.37.1 - 2025-06-03
0.37.0 - 2025-06-03
0.36.0 - 2025-05-27
0.35.1 - 2025-05-20
0.35.0 - 2025-05-13
0.34.2 - 2025-05-06
0.34.1 - 2025-04-29
0.34.0 - 2025-04-22
0.33.0 - 2025-04-15
0.32.1 - 2025-04-07
0.32.0 - 2025-04-02
0.31.0 - 2025-03-18
0.30.0 - 2025-02-11
0.29.0 - 2025-02-04
0.28.0 - 2025-01-21
0.27.0 - 2025-01-07
0.26.0 - 2024-12-17
0.25.0 - 2024-11-12
0.24.0 - 2024-10-22
0.23.0 - 2024-09-25
0.22.0 - 2024-08-27
0.21.0 - 2024-07-30
0.20.1 - 2024-07-16
0.20.0 - 2024-07-09
0.19.1 - 2024-06-25
0.19.0 - 2024-06-04
0.18.1 - 2024-05-22
0.18.0 - 2024-05-14
0.17.1 - 2024-04-08
0.17.0 - 2024-04-01
0.16.0 - 2024-03-01
0.15.0 - 2024-01-16
0.14.1 - 2023-12-18
0.14.0 - 2023-11-23
0.13.1 - 2023-10-23
0.13.0 - 2023-09-21
0.12.0 - 2023-08-24
0.11.0 - 2023-08-10
0.10.0 - 2023-07-20
0.9.1 - 2023-07-11
0.9.0 - 2023-06-13
0.8.0 - 2023-05-16
0.7.0 - 2023-04-28
0.6.1 - 2023-03-28
0.6.0 - 2023-03-24
0.5.0 - 2023-03-13
0.4.0 - 2023-03-02
0.3.0 - 2023-01-06
0.2.0 - 2022-12-01
0.1.0 - 2022-11-07
Python
0.73.0 - 2026-03-10
0.72.0 - 2026-02-26
0.71.0 - 2026-02-17
0.70.0 - 2026-01-27
0.69.0 - 2026-01-13
0.68.2 - 2026-01-06
0.68.1 - 2025-12-16
0.68.0 - 2025-12-09
0.67.0 - 2025-12-02
0.66.0 - 2025-11-18
0.65.0 - 2025-11-11
0.64.0 - 2025-09-30
0.63.0 - 2025-09-02
0.62.0 - 2025-08-19
0.61.0 - 2025-08-12
0.60.0 - 2025-08-05
0.59.0 - 2025-07-15
0.58.0 - 2025-07-08
0.57.1 - 2025-06-17
0.57.0 - 2025-06-10
0.56.0 - 2025-06-03
0.55.1 - 2025-06-02
0.55.0 - 2025-05-29
0.54.0 - 2025-05-13
0.53.0 - 2025-04-29
0.52.0 - 2025-04-15
0.51.0 - 2025-04-08
0.50.0 - 2025-03-18
0.49.0 - 2025-03-04
0.48.0 - 2025-01-21
0.47.0 - 2024-12-17
0.46.0 - 2024-12-10
0.45.0 - 2024-11-12
0.44.1 - 2024-10-29
0.44.0 - 2024-10-22
0.43.1 - 2024-10-15
0.43.0 - 2024-10-09
0.42.0 - 2024-09-23
0.41.0 - 2024-09-03
0.40.0 - 2024-08-27
0.39.3 - 2024-08-20
0.39.2 - 2024-08-13
0.39.1 - 2024-08-13
0.39.0 - 2024-07-30
0.38.0 - 2024-07-23
0.37.0 - 2024-07-09
0.36.3 - 2024-07-02
0.36.2 - 2024-06-25
0.36.1 - 2024-06-18
0.36.0 - 2024-06-11
0.35.0 - 2024-06-04
0.34.1 - 2024-05-21
0.34.0 - 2024-05-14
0.33.0 - 2024-04-16
0.32.0 - 2024-04-04
0.31.1 - 2024-03-20
0.31.0 - 2024-03-05
0.30.0 - 2024-02-22
0.29.0 - 2024-02-13
0.28.0 - 2024-02-01
0.27.0 - 2024-01-23
0.26.0 - 2024-01-16
0.25.0 - 2024-01-09
0.24.1 - 2023-12-15
0.24.0 - 2023-11-23
0.23.1 - 2023-11-10
0.23.0 - 2023-10-26
0.22.1 - 2023-10-24
0.22.0 - 2023-10-23
0.21.0 - 2023-10-11
0.20.0 - 2023-09-21
0.19.1 - 2023-09-08
0.19.0 - 2023-08-25
0.18.1 - 2023-08-16
0.18.0 - 2023-08-14
0.17.0 - 2023-08-10
0.16.1 - 2023-08-03
0.16.0 - 2023-07-25
0.15.2 - 2023-07-19
0.15.1 - 2023-07-06
0.15.0 - 2023-07-05
0.14.1 - 2023-06-16
0.14.0 - 2023-06-14
0.13.0 - 2023-06-02
0.12.0 - 2023-05-01
0.11.0 - 2023-04-13
0.10.0 - 2023-04-07
0.9.0 - 2023-03-10
0.8.1 - 2023-03-05
0.8.0 - 2023-03-03
0.7.0 - 2023-01-10
0.6.0 - 2022-12-02
0.5.0 - 2022-11-07
0.4.0 - 2022-09-14
0.3.0 - 2022-08-30
HTTP API
0.35.0 - 2025-08-19
0.34.1 - 2025-06-17
0.34.0 - 2025-06-09
0.33.0 - 2024-12-10
0.32.0 - 2024-11-26
0.31.0 - 2024-11-12
0.30.0 - 2024-09-24
0.29.0 - 2024-09-03
0.28.0 - 2024-06-25
0.27.0 - 2024-06-04
0.26.0 - 2024-05-14
0.25.0 - 2024-03-26
0.24.0 - 2024-03-06
0.23.0 - 2024-02-15
0.22.0 - 2024-02-06
0.21.0 - 2024-01-30
0.20.0 - 2024-01-18
0.19.0 - 2023-10-17
0.18.0 - 2023-10-11
0.17.0 - 2023-10-04
0.16.0 - 2023-09-26
0.15.0 - 2023-09-19
0.14.0 - 2023-08-29
0.13.0 - 2023-08-23
0.12.0 - 2023-08-10
0.11.0 - 2023-07-25
0.10.0 - 2023-07-06
0.9.0 - 2023-06-01
0.8.0 - 2023-05-01
0.7.0 - 2023-04-07
0.6.0 - 2023-03-10
0.5.0 - 2023-03-03
0.4.0 - 2022-12-02
0.3.0 - 2022-08-30
0.2.0 - 2021-12-10
0.1.0 - 2021-08-30
Raw API
0.8.0 - TBD
0.7.5 - 2026-02-28
0.7.4 - 2026-02-15
0.7.3 - 2026-02-10
0.7.2 - 2025-12-14
0.7.1 - 2025-11-09
0.7.0 - 2025-10-26
0.6.4 - 2025-09-28
0.6.3 - 2025-09-07
0.6.2 - 2025-08-02
0.6.1 - 2025-06-29
0.6.0 - 2025-05-24
0.5.6 - 2025-04-06
0.5.5 - 2024-12-01
0.5.4 - 2024-10-02
0.5.3 - 2024-10-02
0.5.1 - 2024-07-24
2024-07-20
2024-06-25
0.5.0 - 2024-05-25
0.4.6 - 2024-04-13
0.4.5 - 2024-03-25
0.4.4 - 2024-03-23
0.4.3 - 2024-02-13
0.4.2 - 2024-01-06
0.4.0 - 2023-11-08
0.3.0 - 2023-10-20
0.2.0 - 2023-07-23
0.1.0 - 2023-05-01
Rust
0.44.0 - 2026-03-17
0.43.0 - 2026-03-04
0.42.0 - 2026-02-24
0.41.0 - 2026-02-18
0.40.0 - 2026-01-27
0.39.0 - 2026-01-20
0.38.0 - 2025-12-16
0.37.0 - 2025-12-09
0.36.0 - 2025-11-19
0.35.0 - 2025-10-22
0.34.1 - 2025-09-30
0.34.0 - 2025-09-23
0.33.1 - 2025-08-26
0.33.0 - 2025-08-19
0.32.0 - 2025-08-12
0.31.0 - 2025-07-30
0.30.0 - 2025-07-22
0.29.0 - 2025-07-15
0.28.0 - 2025-07-01
0.27.1 - 2025-06-25
0.27.0 - 2025-06-10
0.26.2 - 2025-06-03
0.26.1 - 2025-05-30
0.26.0 - 2025-05-28
0.25.0 - 2025-05-13
0.24.0 - 2025-04-22
0.23.0 - 2025-04-15
0.22.0 - 2025-04-01
0.21.0 - 2025-03-18
0.20.0 - 2025-02-12
0.19.0 - 2025-01-21
0.18.0 - 2025-01-08
0.17.0 - 2024-12-17
0.16.0 - 2024-11-12
0.15.0 - 2024-10-22
0.14.1 - 2024-10-08
0.14.0 - 2024-10-01
0.13.0 - 2024-09-25
0.12.1 - 2024-08-27
0.12.0 - 2024-07-30
0.11.4 - 2024-07-16
0.11.3 - 2024-07-09
0.11.2 - 2024-06-25
0.11.1 - 2024-06-11
0.11.0 - 2024-06-04
0.10.0 - 2024-05-22
0.9.1 - 2024-05-15
0.9.0 - 2024-05-14
0.8.0 - 2024-04-01
0.7.1 - 2024-03-05
0.7.0 - 2024-03-01
0.6.0 - 2024-01-16
0.5.0 - 2023-11-23
0.4.2 - 2023-10-23
0.4.1 - 2023-10-06
0.4.0 - 2023-09-21
0.3.0 - 2023-09-13
0.2.1 - 2023-08-25
0.2.0 - 2023-08-10
0.1.0 - 2023-08-02
Data
2025-11-09
2025-11-04
2025-09-23
2025-08-26
2025-08-05
2025-07-25
2025-07-06
2025-07-01
2025-06-27
2025-06-17
2025-06-10
2025-05-20
2025-05-07
2025-04-05
2025-04-01
2025-03-13
2025-02-26
2025-02-01
2025-01-15
2024-12-14
2024-12-03
2024-12-02
2024-10-22
2024-10-24
2024-07-05
2024-06-25
2024-06-18
2024-05-07
2024-01-18
2023-11-17
2023-10-04
2023-08-29
2023-07-23
2023-05-01
2023-04-28
2023-03-07
Collapse all
Examples and tutorials
Options
Get end of day option spreads
Overview
In this example, we'll use the Historical client to get the end of day spread for an options chain.
First, we'll use the definition schema, which contains instrument definitions and properties, to get information such as expiration, strike_price, and instrument_class.
We'll also use the CBBO-1m schema to get the bid/ask spread for each option.
We'll plot the end-of-day midprice and spread in basis-points (BPS) across all strikes for multiple expirations.
Example
import datetime as dt
from zoneinfo import ZoneInfo
import databento as db
import matplotlib.pyplot as plt
import pandas as pd
def get_options_data(
client: db.Historical,
symbol: str,
schema: str,
start: dt.datetime,
end: dt.datetime | None = None,
) -> pd.DataFrame:
"""Fetch options data between timestamps"""
return client.timeseries.get_range(
dataset="OPRA.PILLAR",
schema=schema,
stype_in="parent",
symbols=f"{symbol}.OPT",
start=start,
end=end,
).to_df()
def combine_data(
trade_date: dt.date,
df_def: pd.DataFrame,
df_close: pd.DataFrame,
) -> pd.DataFrame:
"""Combine open and close data with proper column naming"""
df_close = df_close.groupby("symbol")[["bid_px_00", "ask_px_00"]].last()
df_def = df_def[["symbol", "instrument_class", "expiration", "strike_price"]]
df_def["dte"] = (df_def["expiration"].dt.tz_localize(None) - pd.Timestamp(trade_date)).dt.days
df_def = df_def.set_index("symbol")
df = df_close.join(df_def, on="symbol", how="left").reset_index().sort_values("symbol")
# Calculate spreads in basis points
df["mid_px"] = (df["bid_px_00"] + df["ask_px_00"]) / 2
df["spread"] = df["ask_px_00"] - df["bid_px_00"]
df["spread_bps"] = (df["spread"] / df["mid_px"]) / 1e-4
df["trade_date"] = trade_date
return df
def plot_spreads(
symbol: str,
df: pd.DataFrame,
target_dtes: tuple[int],
) -> None:
"""Plot bid-ask spreads for selected expirations"""
fig, axes = plt.subplots(len(target_dtes), 1, figsize=(12, 12))
selected_expirations = [
df.loc[(df["dte"] - t).abs().idxmin(), "expiration"]
for t in target_dtes
]
subset = df[df["expiration"].isin(selected_expirations)]
y_min = subset["mid_px"].min()
y_max = subset["mid_px"].max()
y_range = y_max - y_min
x_min = subset["strike_price"].min()
x_max = subset["strike_price"].max()
x_padding = (x_max - x_min) * 0.02
y_padding = y_range * 0.1
# 10% of y_range = 1000 bps
y_spread_scale = (y_range * 0.10) / 1000
for idx, (ax, exp) in enumerate(zip(axes, selected_expirations)):
df_exp = df[df["expiration"] == exp].copy()
# Scale spreads for visualization
df_exp["scaled_spread"] = df_exp["spread_bps"].apply(lambda x: x * y_spread_scale)
def plot_options(
instrument_class: db.InstrumentClass,
color: str,
) -> None:
data = df_exp[df_exp["instrument_class"] == instrument_class].sort_values("strike_price")
if len(data) > 0:
half = data["scaled_spread"] / 2
ax.vlines(
x=data["strike_price"],
ymin=data["mid_px"] - half,
ymax=data["mid_px"] + half,
colors=color,
linewidth=2,
alpha=0.7,
label=instrument_class.name.capitalize(),
)
for y_offset in (half, -half):
ax.hlines(
y=data["mid_px"] + y_offset,
xmin=data["strike_price"] - 0.5,
xmax=data["strike_price"] + 0.5,
colors=color,
linewidth=1.5,
alpha=0.7,
)
ax.plot(data["strike_price"], data["mid_px"], "s", color=color, markersize=3)
plot_options(db.InstrumentClass.CALL, "C0")
plot_options(db.InstrumentClass.PUT, "C1")
ref_x = x_max - (x_max - x_min) * 0.05
ref_y_base = y_min * 0.3
s1000 = y_spread_scale * 1000
ax.plot([ref_x, ref_x], [ref_y_base, ref_y_base + s1000], "k-", linewidth=2)
for y_off, label in [(0, "0 bps"), (s1000, "1,000 bps")]:
ax.hlines(
y=ref_y_base + y_off,
xmin=ref_x - 1,
xmax=ref_x + 1,
colors="black",
linewidth=1.5,
)
ax.text(
ref_x - 3,
ref_y_base + y_off,
label,
fontsize=8,
va="center",
ha="right",
)
ax.annotate(
f"DTE = {df_exp['dte'].iloc[0]} days",
xy=(0.02, 0.98),
xycoords="axes fraction",
fontsize=11,
ha="left",
va="top",
bbox=dict(boxstyle="round,pad=0.3", fc="white", ec="gray", alpha=0.8),
)
ax.set_xlim(x_min - x_padding, x_max + x_padding)
ax.set_ylim(y_min - y_padding, y_max + y_padding)
ax.set_ylabel("Option Price ($)", fontsize=11)
ax.grid(True, alpha=0.3)
ax.legend(loc="upper right")
fig.suptitle(f"{symbol} Options End of Day NBBO ({df['trade_date'].iloc[0]})")
fig.supxlabel("Strike Price ($)", fontsize=11)
plt.tight_layout()
plt.show()
symbol = "AAPL"
start_date = dt.date(2025, 11, 19)
close_time = dt.time(16, 0, 0, tzinfo=ZoneInfo("US/Eastern"))
close_dt = dt.datetime.combine(start_date, close_time)
client = db.Historical("YOUR_API_KEY")
df_close = get_options_data(client, symbol, "cbbo-1m", close_dt - dt.timedelta(minutes=15), close_dt)
df_definition = get_options_data(client, symbol, "definition", start_date)
df = combine_data(start_date, df_definition, df_close)
print(df)
# Plot spreads for targeted DTEs
plot_spreads(symbol, df, target_dtes=(0, 30, 60))
Result
symbol bid_px_00 ask_px_00 instrument_class expiration ... dte mid_px spread spread_bps trade_date
0 AAPL 251121C00100000 167.30 168.55 C 2025-11-21 00:00:00+00:00 ... 2 167.925 1.25 74.437993 2025-11-19
1 AAPL 251121C00105000 162.30 165.25 C 2025-11-21 00:00:00+00:00 ... 2 163.775 2.95 180.125172 2025-11-19
2 AAPL 251121C00110000 157.25 160.25 C 2025-11-21 00:00:00+00:00 ... 2 158.750 3.00 188.976378 2025-11-19
3 AAPL 251121C00115000 152.25 155.25 C 2025-11-21 00:00:00+00:00 ... 2 153.750 3.00 195.121951 2025-11-19
4 AAPL 251121C00120000 147.25 150.25 C 2025-11-21 00:00:00+00:00 ... 2 148.750 3.00 201.680672 2025-11-19
... ... ... ... ... ... ... ... ... ... ... ...
2690 AAPL 280121P00490000 219.00 224.00 P 2028-01-21 00:00:00+00:00 ... 793 221.500 5.00 225.733634 2025-11-19
2691 AAPL 280121P00500000 229.00 234.00 P 2028-01-21 00:00:00+00:00 ... 793 231.500 5.00 215.982721 2025-11-19
2692 AAPL 280121P00510000 239.00 244.00 P 2028-01-21 00:00:00+00:00 ... 793 241.500 5.00 207.039337 2025-11-19
2693 AAPL 280121P00520000 249.00 254.00 P 2028-01-21 00:00:00+00:00 ... 793 251.500 5.00 198.807157 2025-11-19
2694 AAPL 280121P00530000 259.00 264.00 P 2028-01-21 00:00:00+00:00 ... 793 261.500 5.00 191.204589 2025-11-19
[2695 rows x 11 columns]