Source: https://databento.com/docs/api-live/client/unsubscribe


### Live.unsubscribe

Remove the specified symbols from the session's subscriptions for a schema.

The symbols don't need to match an earlier [Live.subscribe](https://databento.com/docs/api-live/client/subscribe.md) call: any subset of the subscribed symbols can be removed, and `'ALL_SYMBOLS'` removes every symbol for the schema.

The gateway acknowledges the request with a `SystemMsg` with [system code](https://databento.com/docs/api-live/basics/system-messages.md) `UNSUBSCRIBE_ACK`.
Symbols that aren't subscribed, or that can't be removed with the given `stype_in`, are left in place and reported in an `ErrorMsg`.

The unsubscribe's `stype_in` must be compatible with the subscription's `stype_in`.

| Subscribed with | Can unsubscribe with |
| `'raw_symbol'`, `'instrument_id'`, or `'continuous'` | `'raw_symbol'` or `'instrument_id'` |
| `'parent'` | `'parent'` |

To remove a continuous symbol, unsubscribe the raw symbol or instrument ID that it resolved to at subscription time.

A client can only unsubscribe after a successful connection is made by calling [Live.subscribe](https://databento.com/docs/api-live/client/subscribe.md).
When the `Live` client reconnects with a `reconnect_policy` of `'reconnect'`, subscriptions and unsubscriptions are replayed in the order they were sent.

#### API method

```python
Live.unsubscribe(
    schema: Schema | str,
    symbols: Iterable[str | int] | str | int,
    stype_in: SType | str = "raw_symbol",
) -> None
```

#### Parameters

| Parameter | Type | Required | Description |
| `schema` | Schema or str | required | The data record [schema](https://databento.com/docs/schemas/whats-a-schema.md) to unsubscribe from. |
| `symbols` | Iterable[str \ | int] or str or int | required | The product symbols to unsubscribe from. `'ALL_SYMBOLS'` removes every symbol for the schema. |
| `stype_in` | SType or str, default 'raw_symbol' | optional | The [symbology type](https://databento.com/docs/api-historical/basics/symbology.md) of input `symbols`. Must be one of 'raw_symbol', 'parent', or 'instrument_id'. |

#### Example usage

```python
import databento as db

# Create a live client
client = db.Live(key="$YOUR_API_KEY")

# Subscribe to the trades schema for ES and NQ futures
client.subscribe(
    dataset="GLBX.MDP3",
    schema="trades",
    stype_in="parent",
    symbols=["ES.FUT", "NQ.FUT"],
)

# Start the streaming session
client.start()

# Stop receiving trades for NQ futures
client.unsubscribe(
    schema="trades",
    stype_in="parent",
    symbols="NQ.FUT",
)

# Terminate the streaming session
client.terminate()
```
