Skip to content

Instantly share code, notes, and snippets.

@databento-bot
Last active December 4, 2025 09:59
Show Gist options
  • Select an option

  • Save databento-bot/f3dbb0cd5714a8cb49742e828382a70a to your computer and use it in GitHub Desktop.

Select an option

Save databento-bot/f3dbb0cd5714a8cb49742e828382a70a to your computer and use it in GitHub Desktop.
Minimal example of requesting equity options on Databento with OCC symbology
import databento as db
client = db.Historical("YOUR_API_KEY")
# Requesting a specific strike
data = client.timeseries.get_range(
dataset="OPRA.PILLAR",
schema="cmbp-1",
stype_in="raw_symbol",
symbols=["SPY 241115P00525000"],
start="2024-08-09T09:30-04:00",
end="2024-08-09T10:00-04:00",
)
df = data.to_df()
print(df[["symbol", "bid_px_00", "ask_px_00"]].head())
# Working with individual raw symbols can be tedious. Many users find it easier to specify the
# underlying's symbol and fetch all option symbols for that underlying in an option chain at once.
# This can be done using our parent symbology by passing in stype_in="parent" to your request.
data = client.timeseries.get_range(
dataset="OPRA.PILLAR",
schema="trades",
stype_in="parent",
symbols=["AAPL.OPT"],
start="2024-08-09T09:30-04:00",
end="2024-08-09T10:00-04:00",
)
df = data.to_df()
print(df[["symbol", "price"]])
symbol bid_px_00 ask_px_00
ts_recv
2024-08-09 13:30:00.025137089+00:00 SPY 241115P00525000 16.33 16.53
2024-08-09 13:30:00.167110712+00:00 SPY 241115P00525000 16.33 16.52
2024-08-09 13:30:00.182316856+00:00 SPY 241115P00525000 16.34 16.51
2024-08-09 13:30:00.238455572+00:00 SPY 241115P00525000 16.34 16.50
2024-08-09 13:30:00.340439305+00:00 SPY 241115P00525000 16.34 16.51
symbol price
ts_recv
2024-08-09 13:30:00.008689345+00:00 AAPL 240809C00217500 0.06
2024-08-09 13:30:00.021880156+00:00 AAPL 240816C00230000 0.10
2024-08-09 13:30:00.032886565+00:00 AAPL 240920P00175000 0.77
2024-08-09 13:30:00.036991612+00:00 AAPL 240809P00202500 0.08
2024-08-09 13:30:00.109699333+00:00 AAPL 240816C00215000 2.23
... ... ...
2024-08-09 13:59:58.801315993+00:00 AAPL 240816C00207500 6.80
2024-08-09 13:59:58.962219427+00:00 AAPL 240809C00212500 1.24
2024-08-09 13:59:59.036621416+00:00 AAPL 240816C00240000 0.02
2024-08-09 13:59:59.124512360+00:00 AAPL 240809C00212500 1.24
2024-08-09 13:59:59.858997181+00:00 AAPL 240809C00220000 0.02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment