Historical.timeseries.get_range

Makes a streaming request for time series data from Databento.

This is the primary method for getting historical market data, instrument definitions, and status data directly into your application.

This method only returns after all of the data has been downloaded, which can take a long time. For large requests, consider using batch.submit_job instead.

Parameters

Parameter
Type
Required
Description
dataset
Dataset or str
required
The dataset code (string identifier). Must be one of the values from list_datasets.
start
pd.Timestamp, datetime, date, str, or int
required
The inclusive start of the request range. Filters on ts_recv if it exists in the schema, otherwise ts_event. Takes pd.Timestamp, Python datetime, Python date, ISO 8601 string, or UNIX timestamp in nanoseconds. Assumes UTC as timezone unless otherwise specified.
end
pd.Timestamp, datetime, date, str, or int
optional
The exclusive end of the request range. Filters on ts_recv if it exists in the schema, otherwise ts_event. Takes pd.Timestamp, Python datetime, Python date, ISO 8601 string, or UNIX timestamp in nanoseconds. Assumes UTC as timezone unless otherwise specified. Defaults to the forward filled value of start based on the resolution provided.
symbols
Iterable[str | int] or str or int
optional
The product symbols to filter for. Takes up to 2,000 symbols per request. If more than 1 symbol is specified, the data is merged and sorted by time. If 'ALL_SYMBOLS' or None then will select all symbols.
schema
Schema or str, default 'trades'
optional
The data record schema. Must be one of the values from list_schemas.
stype_in
SType or str, default 'raw_symbol'
optional
The symbology type of input symbols. Must be one of 'raw_symbol', 'instrument_id', 'parent', or 'continuous'.
stype_out
SType or str, default 'instrument_id'
optional
The symbology type of output symbols. Must be one of 'raw_symbol', 'instrument_id', 'parent', or 'continuous'. Must be a valid symbology combination with stype_in. See symbology combinations.
limit
int
optional
The maximum number of records to return. If None then no limit.
path
PathLike[str] or str
optional
The file path to stream the data to. It is recommended to use the ".dbn.zst" suffix.

Returns

A DBNStore object.

A full list of fields for each schema is available through Historical.metadata.list_fields.

API method
1
2
3
4
5
6
7
8
9
10
11
Historical.timeseries.get_range(
    dataset: Dataset | str,
    start: pd.Timestamp | datetime | date | str | int,
    end: pd.Timestamp | datetime | date | str | int | None = None,
    symbols: Iterable[str | int] | str | int | None = None,
    schema: Schema | str = "trades",
    stype_in: SType | str = "raw_symbol",
    stype_out: SType | str = "instrument_id",
    limit: int | None = None,
    path: PathLike[str] | str | None = None,
) -> DBNStore
Example usage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import databento as db

client = db.Historical("$YOUR_API_KEY")

data = client.timeseries.get_range(
    dataset="GLBX.MDP3",
    symbols=["ESM2"],
    schema="trades",
    start="2022-06-06T00:00:00",
    end="2022-06-10T00:10:00",
    limit=1,
)
df = data.to_df()
print(df.iloc[0].to_json(indent=4))
Example response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
    "ts_event":1654473600070,
    "rtype":0,
    "publisher_id":1,
    "instrument_id":3403,
    "action":"T",
    "side":"A",
    "depth":0,
    "price":4108.5,
    "size":1,
    "flags":0,
    "ts_in_delta":18681,
    "sequence":157862,
    "symbol":"ESM2"
}