This example builds off the Join schemas on instrument ID example.
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
Blue Ocean ATS MEMOIR Depth
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 Texas 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.61.0 - 2026-07-07
0.60.0 - 2026-06-16
0.59.0 - 2026-06-02
0.58.0 - 2026-05-26
0.57.0 - 2026-05-12
0.56.0 - 2026-05-05
0.55.0 - 2026-04-28
0.54.0 - 2026-04-21
0.53.0 - 2026-04-08
0.52.0 - 2026-03-31
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.81.0 - 2026-07-07
0.80.0 - 2026-06-16
0.79.0 - 2026-06-02
0.78.0 - 2026-05-12
0.77.0 - 2026-04-28
0.76.0 - 2026-04-21
0.75.0 - 2026-04-07
0.74.1 - 2026-03-31
0.74.0 - 2026-03-24
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.36.0 - TBD
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.9.1 - TBD
0.9.0 - 2026-04-26
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.54.0 - 2026-07-07
0.53.0 - 2026-06-02
0.52.0 - 2026-05-26
0.51.0 - 2026-05-12
0.50.0 - 2026-05-05
0.49.0 - 2026-04-29
0.48.0 - 2026-04-21
0.47.0 - 2026-04-15
0.46.0 - 2026-04-07
0.45.0 - 2026-03-31
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
Upcoming
2026-05-31
2026-05-09
2026-04-22
2026-04-15
2026-04-13
2026-04-08
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
Join options with underlying prices
Info
Overview
In this example, we'll use the Historical client to data for futures and options. First, we'll request trades schema data for all options on the volume-based continuous contract and join them with the most recent quote from the MBP-1 schema for the underlying future. We'll also request BBO-1m schema data for the underlying future and a single option and plot the midprice for a full session.
Example
import databento as db
import matplotlib.dates as mdates
import matplotlib.pyplot as plt
import pandas as pd
def get_bbo_data(
dataset: str,
instrument_id: int,
start: str,
end: str,
) -> pd.DataFrame:
mbp_df = client.timeseries.get_range(
dataset=dataset,
schema="bbo-1m",
symbols=instrument_id,
stype_in="instrument_id",
start=start,
end=end,
).to_df(map_symbols=False)
return mbp_df[["instrument_id", "bid_px_00", "ask_px_00"]]
def plot_option_with_underlying(
opt_df: pd.DataFrame,
fut_df: pd.DataFrame,
) -> None:
opt_df["mid_price"] = (opt_df["bid_px_00"] + opt_df["ask_px_00"]) / 2
fut_df["mid_price"] = (fut_df["bid_px_00"] + fut_df["ask_px_00"]) / 2
full_index = pd.date_range(
start=start,
end=end,
freq="1min",
tz="UTC",
inclusive="right",
)
opt_df = opt_df.reindex(full_index).ffill().astype(opt_df.dtypes)
fut_df = fut_df.reindex(full_index).ffill().astype(fut_df.dtypes)
opt_symbol = opt_df["raw_symbol"].iloc[0]
fut_symbol = opt_df["underlying"].iloc[0]
fig, ax1 = plt.subplots(figsize=(14, 6))
ax1.plot(fut_df.index, fut_df["mid_price"], color="C0", label=fut_symbol)
ax1.set_ylabel(f"Futures midprice ({fut_symbol})", color="C0")
ax1.tick_params(axis="y", labelcolor="C0")
strike = opt_df["strike_price"].iloc[0]
ax1.axhline(y=strike, color="gray", linestyle="--")
ax1.text(
x=fut_df.index[0],
y=strike,
s=f"Strike price: {strike:.0f}",
color="gray",
va="bottom",
ha="left",
)
ax2 = ax1.twinx()
ax2.plot(opt_df.index, opt_df["mid_price"], color="C1", label=opt_symbol)
ax2.set_ylabel(f"Options midprice ({opt_symbol})", color="C1")
ax2.tick_params(axis="y", labelcolor="C1")
ax1.xaxis.set_major_formatter(mdates.DateFormatter("%H:%M"))
ax1.xaxis.set_major_locator(mdates.HourLocator(interval=1))
ax1.set_title("Futures vs. Options Midprice")
ax1.set_xlabel("Time (UTC)")
lines1, labels1 = ax1.get_legend_handles_labels()
lines2, labels2 = ax2.get_legend_handles_labels()
ax1.legend(lines1 + lines2, labels1 + labels2, loc="upper left")
ax1.grid(True)
ax2.grid(False)
fig.tight_layout()
plt.show()
# Create a historical client
client = db.Historical("$YOUR_API_KEY")
# Set parameters
dataset = "GLBX.MDP3"
symbol = "CL.v.0"
start = "2026-04-12T22:00:00"
end = "2026-04-13T21:00:00"
# Get symbol mapping for the continuous contract
symbol_map = client.symbology.resolve(
dataset=dataset,
symbols=symbol,
stype_in="continuous",
stype_out="instrument_id",
start_date="2026-04-12",
)
# Get instrument ID for the resolved futures contract
fut_id = int(symbol_map["result"][symbol][0]["s"])
# Get all option definitions
def_df = client.timeseries.get_range(
dataset=dataset,
symbols="ALL_SYMBOLS",
schema="definition",
start="2026-04-12",
).to_df()
# Filter for options with the continuous contract as an underlying
opt_def_df = def_df[
(def_df["user_defined_instrument"] == db.UserDefinedInstrument.NO) &
(def_df["instrument_class"].isin((db.InstrumentClass.CALL, db.InstrumentClass.PUT))) &
(def_df["underlying_id"] == fut_id)
]
opt_def_df = opt_def_df[["ts_event", "expiration", "raw_symbol", "instrument_id", "asset", "strike_price", "underlying", "underlying_id", "instrument_class"]]
# Get trades data for the filtered options
opt_trades_df = client.timeseries.get_range(
dataset=dataset,
schema="trades",
symbols=[f"{x}.OPT" for x in opt_def_df["asset"].unique()],
stype_in="parent",
start=start,
end=end,
).to_df().rename(columns={"size": "trade_size", "price": "trade_price", "side": "trade_side"})
# Join options with their definitions
opt_df = opt_trades_df.reset_index().merge(
opt_def_df.reset_index(),
on="instrument_id",
how="inner",
suffixes=("", "_def"),
).set_index("ts_recv").sort_index()
fut_mbp_df = client.timeseries.get_range(
dataset=dataset,
schema="mbp-1",
symbols=fut_id,
stype_in="instrument_id",
start=start,
end=end,
).to_df()
fut_mbp_df = fut_mbp_df.rename(
columns={
"bid_px_00": "underlying_bid",
"ask_px_00": "underlying_ask",
},
)[["underlying_bid", "underlying_ask"]]
# Join most recent underlying bid/ask with options trades
df = pd.merge_asof(
opt_df,
fut_mbp_df,
left_index=True,
right_index=True,
direction="backward",
)
print(df[["ts_event", "instrument_id", "raw_symbol", "trade_price", "trade_size", "trade_side", "strike_price", "instrument_class", "expiration", "underlying_bid", "underlying_ask"]])
# 42963414 is the `instrument_id` for NL2J6 P10000
opt_id = 42963414
opt_bbo_df = get_bbo_data(dataset, opt_id, start, end)
opt_bbo_df = opt_bbo_df.reset_index().merge(opt_def_df, on="instrument_id", how="left").set_index("ts_recv")
fut_bbo_df = get_bbo_data(dataset, fut_id, start, end)
plot_option_with_underlying(opt_bbo_df, fut_bbo_df)
Result
We can see all trades for options that have the volume-based continuous contract as an underlying.
ts_event instrument_id raw_symbol trade_price trade_size ... strike_price instrument_class expiration underlying_bid underlying_ask
ts_recv ...
2026-04-12 22:00:00.356333832+00:00 2026-04-12 22:00:00+00:00 42157669 LOK6 C9900 6.01 1 ... 99.00 C 2026-04-16 18:30:00+00:00 NaN NaN
2026-04-12 22:00:00.356370138+00:00 2026-04-12 22:00:00+00:00 42180553 LOK6 P8200 0.39 1 ... 82.00 P 2026-04-16 18:30:00+00:00 NaN NaN
2026-04-12 22:00:00.357402871+00:00 2026-04-12 22:00:00+00:00 42511805 ML2J6 C10000 2.40 2 ... 100.00 C 2026-04-13 18:30:00+00:00 NaN NaN
2026-04-12 22:00:00.357526014+00:00 2026-04-12 22:00:00+00:00 42639465 ML2J6 P9100 0.74 1 ... 91.00 P 2026-04-13 18:30:00+00:00 NaN NaN
2026-04-12 22:00:00.357609934+00:00 2026-04-12 22:00:00+00:00 42963412 NL2J6 P9600 0.99 1 ... 96.00 P 2026-04-14 18:30:00+00:00 NaN NaN
... ... ... ... ... ... ... ... ... ... ... ...
2026-04-13 20:57:18.223377118+00:00 2026-04-13 20:57:18.222967937+00:00 42308894 LOK6 P8500 0.27 1 ... 85.00 P 2026-04-16 18:30:00+00:00 97.96 97.98
2026-04-13 20:57:18.223891862+00:00 2026-04-13 20:57:18.223423419+00:00 42308894 LOK6 P8500 0.27 1 ... 85.00 P 2026-04-16 18:30:00+00:00 97.96 97.98
2026-04-13 20:57:19.267462126+00:00 2026-04-13 20:57:19.267057293+00:00 42631933 WL3J6 C9775 3.03 1 ... 97.75 C 2026-04-15 18:30:00+00:00 97.97 97.99
2026-04-13 20:58:04.991697756+00:00 2026-04-13 20:58:04.983728493+00:00 42958534 NL2J6 C10100 0.91 1 ... 101.00 C 2026-04-14 18:30:00+00:00 97.94 97.96
2026-04-13 20:58:38.292464827+00:00 2026-04-13 20:58:38.292053561+00:00 379004 LOK6 P7000 0.02 1 ... 70.00 P 2026-04-16 18:30:00+00:00 97.97 97.99
[17262 rows x 11 columns]
Now we'll plot the midprice of the underlying future and a single option for the duration of a full session.
In this example, the option NL2J6 P10000 expires on 2026-04-14.