# Normalized Data

## Trades

Subscribe to all trades, or only those for a specific instrument:

```python
# Subscribe to all trades on all exchanges
ws.send({action: 'subscribe', channel: ['trade']})

# Subscribe to a single asset on a single exchange
ws.send({action: 'subscribe', channel: ['deribit.BTC-PERPETUAL.trade']})

# Subscribe to all trades for a given asset across all exchanges
ws.send({action: 'subscribe', channel: ['BTCUSD spot.trade']})
```

{% hint style="info" %}
Currently, only asset pairs vs USD are normalized across all exchanges for combined streaming. If you need other pairs please get in touch and we will activate as a priority.
{% endhint %}

The trade subscription returns every trade that occurs as a separate JSON response, such as the below:

```python
{
   "type":"trade",
   "symbol":"XRP3LUSDT",
   "exchange":"huobi",
   "id":"22480463",
   "price":1.9847,
   "amount":10.3907,
   "side":"sell",
   "timestamp":"2021-04-23T06:50:39.289Z",
   "localTimestamp":"2021-04-23T06:52:50.551Z"
}

{
   "type":"trade",
   "symbol":"CRV-USD",
   "exchange":"coinbase",
   "id":"611170",
   "price":2.4331,
   "amount":133.41,
   "side":"sell",
   "timestamp":"2021-04-23T06:50:09.057Z",
   "localTimestamp":"2021-04-23T06:52:50.554Z"
}
```

The responses are normalized for each exchange, but are not adjusted for fees or inverted pricing (e.g. some perpetual swaps).

## Orderbooks

Standard orderbooks are available in customizable snapshots or as deltas, with each response updating the state of the book from the previous message. You can also subscribe to a combined, normalized and fee-adjusted orderbook for all underlying exchanges for a given asset.

```python
# Subscribe to all 1 minute book summaries for all assets on all exchanges
ws.send({action: 'subscribe', channel: ['book_snapshots']})

# Subscribe to Deribit's BTC-PERPETUAL instrument, top 5 levels, updated every 100ms
ws.send({action: 'subscribe', channel: ['deribit.BTC-PERPETUAL.book_snapshot_5_100ms']})

# Subscribe to Bitmex's XBTUSD instrument, best bid and ask, updated on every change
ws.send({action: 'subscribe', channel: ['bitmex.XBTUSD.book_snapshot_1_0ms']}

# Subscribe to book deltas for Deribit's BTC-PERPETUAL
ws.send({action: 'subscribe', channel: ['deribit.BTC-PERPETUAL.book_change']})

# Subscribe to the combined, fee-adjusted orderbook for BTCUSD across all exchanges
ws.send({action: 'subscribe', channel: ['BTCUSD perpetual.combined_orderbook']})
```

{% hint style="info" %}
You must also provide the type (e.g. perpetual, spot) for a Combined Orderbook - perpetuals can trade at a legitimate spread to spot and including them in the same orderbook leads to inconsistency. You can, however, subscribe to both at the same time.
{% endhint %}

The subscription returns a snapshot of the number of bids and asks requested, at the frequency requested - for example:

```python
{
   "type":"book_snapshot",
   "symbol":"BSVBULL/USDT",
   "exchange":"ftx",
   "depth":5,
   "interval":60000,
   "bids":[
      {
         "price":0.0112225,
         "amount":127070
      },
      {
         "price":0.01113,
         "amount":2360
      },
      {
         "price":0.0111275,
         "amount":689720
      },
      {
         "price":0.0110775,
         "amount":848160
      },
      {
         "price":0.011,
         "amount":908910
      }
   ],
   "asks":[
      {
         "price":0.0114675,
         "amount":176670
      },
      {
         "price":0.0115375,
         "amount":170370
      },
      {
         "price":0.0117,
         "amount":720890
      },
      {
         "price":0.0118775,
         "amount":133290
      },
      {
         "price":0.0118925,
         "amount":629000
      }
   ],
   "timestamp":"2021-04-23T06:54:00.000Z",
   "localTimestamp":"2021-04-23T06:56:27.821Z"
}
```

## Pattern Subscriptions

Subscribe to multiple streams in the same request using a pattern subscription, for example you could subscribe to every trade on a given exchange, or every Option and Future on Deribit with a given expiry date.

```python
# Subscribe to all trades on Deribit
ws.send({action: 'subscribe', channel: ['deribit.*.trade']})

# Subscribe to all trades on Deribit in BTC Options and Futures with given expiry
ws.send({action: 'subscribe', channel: ['deribit.BTC-31DEC21*.trade']})

# Subscribe to all channels for BTC-PERPETUAL
ws.send({action: 'subscribe', channel: ['deribit.BTC-PERPETUAL.*']})
```

{% hint style="danger" %}
**NOTE:** Subscribing to all channels can deliver vast amounts of data, including very similar data such as every quantile measurement. Overly broad pattern subscriptions are not recommended unless you have a very specific use case that requires them.
{% endhint %}
