Live.subscribe
Add a new subscription to the session. All subscriptions must be for the same dataset. The returned integer is the subscription_id which will match the id used by the gateway when acknowledging the subscription.
Supports multiple subscriptions for different schemas, which enables rich data streams containing mixed record types.
Specify an optional start time for intraday replay with subscriptions made before starting the session.
Please note there is no unsubscribe method. Subscriptions end when the client disconnects or by calling Live.stop or Live.terminate
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
dataset | Dataset or str | required | The dataset code (string identifier). Must be one of the values from list_datasets. |
schema | Schema or str | required | The data record schema. Must be one of the values from list_schemas. |
symbols | Iterable[str | int] or str or int | optional | The product symbols to subscribe to. If 'ALL_SYMBOLS' or None then will select all symbols. |
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'. |
start | pd.Timestamp, datetime, date, str or int | optional | The inclusive start of subscription replay. Filters on ts_event except for the CBBO and BBO schemas, which filter on ts_recv. Takes pd.Timestamp, Python datetime, Python date, ISO 8601 string, or UNIX timestamp in nanoseconds. Assumes UTC as timezone unless otherwise specified. Must be within the last 24 hours. Pass 0 to request all available data. Cannot be specified after the session is started. |
snapshot | bool, default False | optional | Request subscription with snapshot. Only supported with mbo schema. Defaults to False. Conflicts with the start parameter. |
API method
1 2 3 4 5 6 7 8
Live.subscribe(
dataset: Dataset | str,
schema: Schema | str,
symbols: Iterable[str | int] | str | int = "ALL_SYMBOLS",
stype_in: SType | str = "raw_symbol",
start: pd.Timestamp | datetime | date | str | int | None = None,
snapshot: bool = False,
) -> int Example usage
1 2 3 4 5 6 7 8 9 10 11 12
import databento as db
# Create a live client
client = db.Live(key="$YOUR_API_KEY")
# Subscribe to the trades schema for all ES futures
client.subscribe(
dataset="GLBX.MDP3",
schema="trades",
stype_in="parent",
symbols="ES.FUT",
)