This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| get_atm_options_bbo.py | |
| ============== | |
| Get BBO of ATM options for an underlying stock using Databento. | |
| This example uses the "cbbo-1s" schema for 1-second granularity, but you can substitute | |
| with "cmbp-1" or "cbbo-1m" for higher/lower granularity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| eth_high_low.py | |
| ============== | |
| Calculates daily high/low occurrences for ES futures outside regular US cash session hours | |
| using Databento API. | |
| Fetches second-by-second OHLCV data for ES continuous futures from Databento, | |
| filters to exclude regular US cash session (9:30 AM - 4:00 PM ET), then computes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| cme_fx_link.py | |
| ============== | |
| Retrieve CME FX Link order book (MBO) data using the Databento API. | |
| Databento API を使用して、CME FX Link のオーダーブック | |
| (マーケット・バイ・オーダー)データを取得します。 | |
| """ | |
| import databento as db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Side-by-side comparison of pandas vs. polars syntax for reading CSV and filtering by symbol | |
| import pandas as pd | |
| import polars as pl | |
| CSVFILE = "glbx-mdp3-20250716-20250815.ohlcv-1m.csv.zst" | |
| # Using pandas | |
| df = pd.read_csv(CSVFILE) |
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 18 columns, instead of 15 in line 6.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ts_recv,ts_event,rtype,publisher_id,instrument_id,action,side,price,size,flags,ts_in_delta,bid_px_00,ask_px_00,bid_sz_00,ask_sz_00,bid_pb_00,ask_pb_00,symbol | |
| 2023-03-28 09:30:00.067424405-04:00,2023-03-28 09:30:00.067217664-04:00,177,30,654313225,A,N,326.77,1,194,0,321.77,326.77,1,1,0,0,SPY 241220P00720000 | |
| 2023-03-28 09:30:00.182559853-04:00,2023-03-28 09:30:00.182352128-04:00,177,30,654313225,A,N,,0,194,0,,,0,0,0,0,SPY 241220P00720000 | |
| 2023-03-28 09:30:00.463387013-04:00,2023-03-28 09:30:00.463180032-04:00,177,30,654313225,A,N,329.22,1,194,0,319.22,329.22,1,1,0,0,SPY 241220P00720000 | |
| 2023-03-28 09:30:00.536456272-04:00,2023-03-28 09:30:00.536249088-04:00,177,30,654313225,A,N,328.28,1,194,0,319.22,328.28,1,1,0,0,SPY 241220P00720000 | |
| 2023-03-28 09:30:00.537369130-04:00,2023-03-28 09:30:00.537161984-04:00,177,30,654313225,A,N,318.28,1,194,0,318.28,328.28,1,1,0,0,SPY 241220P00720000 | |
| 2023-03-28 09:30:00.661258449-04:00,2023-03-28 09:30:00.661050624-04:00,177,30,654313225,A,N,328.28,1,194,0,318.28,328.28,2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Databento follows the standard convention of only printing OHLCV records when | |
| trades actually occur within the interval. If no trade occurs within the interval, | |
| no record is printed. | |
| This approach is adopted by most data vendors for two key reasons: | |
| 1. Multiple interpolation strategies exist and the optimal choice depends on the | |
| specific use case. Client-side interpolation keeps the strategy transparent. | |
| 2. This reduces storage and bandwidth requirements, especially for markets with | |
| many illiquid instruments like options. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import databento as db | |
| client = db.Historical() | |
| data = client.timeseries.get_range( | |
| dataset="XNAS.ITCH", | |
| schema="ohlcv-1m", | |
| symbols="AAPL", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import databento as db | |
| import pandas as pd | |
| client = db.Historical() | |
| def print_ng_summary_by_date(date_str: str): | |
| date = pd.to_datetime(date_str) | |
| weekday = date.weekday() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ts_event rtype publisher_id instrument_id action side price size channel_id order_id flags ts_in_delta sequence symbol | |
| ts_recv | |
| 2025-04-25 13:30:00.002415517+00:00 2025-04-25 13:30:00.000435143+00:00 160 1 42003627 F A 5510.25 2 8 6863196218407 0 14070 333790855 MESM5 | |
| 2025-04-25 13:30:00.002415517+00:00 2025-04-25 13:30:00.000435143+00:00 160 1 42003627 F A 5510.25 1 8 6863196218557 0 14070 333790855 MESM5 | |
| 2025-04-25 13:30:00.002415517+00:00 2025-04-25 13:30:00.000435143+00:00 160 1 42003627 F A 5510.50 1 8 6863196218273 0 14070 333790855 MESM5 | |
| 2025-04-25 13:30:00.002495446+00:00 2025-04-25 13:30:00.000756343+00:00 160 1 42003627 F A 5510.50 1 8 6863196218273 0 12976 333790857 MESM5 | |
| 2025-04-25 13:30 |
NewerOlder