# Combined Orderbook

You can access a Combined Orderbook for any currency that trades against USD. This will aggregate all orderbooks across all exchanges where that currency trades, adjust these for the taker fee, and maintain a fee-adjusted orderbook of all bids and asks across all these exchanges.

This gives you the ability to see a true-cost representation of the current market bid/ask, and a better idea of the true mid market price. The Combined Orderbook feeds into execution algorithms, smart order routing and liquidity analyses to determine optimal trade execution routes and to more effectively make markets across exchanges.

```python
ws.send({action: 'subscribe', channel: ['BTCUSD spot'.combined_orderbook]})
```

The Bids and Asks are all adjusted for the first-tier Taker Fee on each exchange, where you pay a different fee due to trading volume incentives or VIP programmes,  you can provide a tailored fee for that exchange.

{% hint style="warning" %}
Fee Adjustment Coming Soon
{% endhint %}

```python
exchanges_fees = {
    'bitmex': -0.0005,
    'deribit': 0,
    'binance': 0
}

payload = {
    action: 'subscribe',
    channel: ['BTCUSD spot.combined_orderbook'],
    fees: exchange_fees
}

ws.send(payload)
```

### Fees Parameters

| Parameter | Type    | Required | Description                                                                   |
| --------- | ------- | -------- | ----------------------------------------------------------------------------- |
| exchange  | string  | no       | Exchange name                                                                 |
| fee       | numeric | no       | Relevant fee expressed as a percentage (e.g. 0.075% (7.5bp) would be 0.00075) |

### Combined Orderbook Returns

The Combined Orderbook subscription returns frequent book snapshots (on every change to the top levels) in the format below:

```javascript
{
   "type":"book_snapshot",
   "bids":[
      {
         "price":49413.18735,
         "amount":0.000006,
         "exchange":"binance-us"
      },
      {
         "price":49410.97956,
         "amount":0.021968,
         "exchange":"binance-us"
      },
      {
         "price":49409.36118,
         "amount":0.02,
         "exchange":"bitflyer"
      },
      {
         "price":49406.45409000001,
         "amount":0.07991,
         "exchange":"binance-us"
      },
      {
         "price":49403.93661,
         "amount":0.071702,
         "exchange":"binance-us"
      }
   ],
   "asks":[
      {
         "price":49524.08461,
         "amount":0.071701,
         "exchange":"binance-us"
      },
      {
         "price":49530.84136,
         "amount":0.121282,
         "exchange":"binance-us"
      },
      {
         "price":49533.854369999994,
         "amount":0.04,
         "exchange":"binance-us"
      },
      {
         "price":49536.76727999999,
         "amount":0.1902,
         "exchange":"bitflyer"
      },
      {
         "price":49537.55806999999,
         "amount":0.0804,
         "exchange":"binance-us"
      }
   ],
   "mid":"49468.64"
}
```

The subscription also returns any trades that occur across any of these instruments in the format below:

```javascript
{
   "type":"trade",
   "symbol":"XBT/USD",
   "exchange":"kraken",
   "price":49471.6,
   "amount":0.02111405,
   "side":"buy",
   "timestamp":"2021-04-23T06:10:25.995Z",
   "localTimestamp":"2021-04-23T06:10:26.493Z",
   "inverse":false,
   "takerFee":0.0026
}

{
   "type":"trade",
   "symbol":"BTCUSD",
   "exchange":"binance-us",
   "id":"11054072",
   "price":49474.61,
   "amount":0.001346,
   "side":"buy",
   "timestamp":"2021-04-23T06:10:26.454Z",
   "localTimestamp":"2021-04-23T06:10:26.495Z",
   "inverse":false,
   "takerFee":0.001
}
```

This shows the price and amount traded, along with whether the amount is inverse (as in some perpetual swaps) and the given taker fee, by default the marginal taker fee for a new trader. The price is **not** adjusted for taker fee, this is the actual reported trade price as per the exchange.

## Adjusted Spreads

{% hint style="warning" %}
Coming Soon
{% endhint %}

You can get the fee-adjusted spread for the asset (i.e. fee adjusted best ask minus fee adjusted best bid) on a streaming asset for any of the Combined Orderbook pairs. This gives a real world indication of the current price of immediacy and is useful in conjunction with the volatility subscription as part of market making strategies.

You can subscrive in the below format:

```python
channel = ['BTCUSD spot.spread']
```

## Orderbook Dynamics

The descriptive statistics outlined in the [Orderbook Dynamics](/streaming/orderbook-dynamics.md) section are also valid on Combined Orderbooks.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cryptostats.dev/streaming/combined-orderbook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
