---
title: Orderbook Functions
description: Order-flow analytics functions for measuring bid and ask depth at configurable depth percentages.
---

Orderbook functions work with orderbook data to analyze market depth, liquidity distribution, and order-flow patterns. They help identify support/resistance levels and market sentiment through bid/ask analysis.

| Category                | Description                                                                                             |
| ----------------------- | ------------------------------------------------------------------------------------------------------- |
| **Volume Analysis**     | Sum bid and ask volumes within specified depth percentages to gauge buying and selling pressure.        |
| **Order Size Analysis** | Identify maximum and minimum order sizes to spot large participants and market microstructure patterns. |
| **Market Depth**        | Analyze liquidity distribution to understand support/resistance levels and potential price impact.      |

| Function                        | Description                                      |
| ------------------------------- | ------------------------------------------------ |
| [`sumBids`](#sumbids)           | Total bid volume within the depth window         |
| [`sumAsks`](#sumasks)           | Total ask volume within the depth window         |
| [`maxBidAmount`](#maxbidamount) | Largest single bid order within the depth window |
| [`maxAskAmount`](#maxaskamount) | Largest single ask order within the depth window |
| [`minBidAmount`](#minbidamount) | Smallest bid order within the depth window       |
| [`minAskAmount`](#minaskamount) | Smallest ask order within the depth window       |

## sumBids

`sumBids(source: TimeSeries, depthPct?: number = 10): number` — total bid volume within `depthPct` of the mid-price.

| Parameter  | Type       | Description                      |
| ---------- | ---------- | -------------------------------- |
| `source`   | TimeSeries | Source orderbook data series     |
| `depthPct` | number     | Depth percentage (default: `10`) |

**Returns:** `number` — total bid volume within depth.

```javascript
var bidVolume = sumBids((source = orderbookData), (depthPct = 10));
```

## sumAsks

`sumAsks(source: TimeSeries, depthPct?: number = 10): number` — total ask volume within `depthPct` of the mid-price.

| Parameter  | Type       | Description                      |
| ---------- | ---------- | -------------------------------- |
| `source`   | TimeSeries | Source orderbook data series     |
| `depthPct` | number     | Depth percentage (default: `10`) |

**Returns:** `number` — total ask volume within depth.

```javascript
var askVolume = sumAsks((source = orderbookData), (depthPct = 10));
```

## maxBidAmount

`maxBidAmount(source: TimeSeries, depthPct?: number = 10): number` — largest single bid order within `depthPct` of the mid-price.

| Parameter  | Type       | Description                      |
| ---------- | ---------- | -------------------------------- |
| `source`   | TimeSeries | Source orderbook data series     |
| `depthPct` | number     | Depth percentage (default: `10`) |

**Returns:** `number` — largest bid order size within depth.

```javascript
var maxBid = maxBidAmount((source = orderbookData), (depthPct = 10));
```

## maxAskAmount

`maxAskAmount(source: TimeSeries, depthPct?: number = 10): number` — largest single ask order within `depthPct` of the mid-price.

| Parameter  | Type       | Description                      |
| ---------- | ---------- | -------------------------------- |
| `source`   | TimeSeries | Source orderbook data series     |
| `depthPct` | number     | Depth percentage (default: `10`) |

**Returns:** `number` — largest ask order size within depth.

```javascript
var maxAsk = maxAskAmount((source = orderbookData), (depthPct = 10));
```

## minBidAmount

`minBidAmount(source: TimeSeries, depthPct?: number = 10): number` — smallest bid order within `depthPct` of the mid-price.

| Parameter  | Type       | Description                      |
| ---------- | ---------- | -------------------------------- |
| `source`   | TimeSeries | Source orderbook data series     |
| `depthPct` | number     | Depth percentage (default: `10`) |

**Returns:** `number` — smallest bid order size within depth.

```javascript
var minBid = minBidAmount((source = orderbookData), (depthPct = 10));
```

## minAskAmount

`minAskAmount(source: TimeSeries, depthPct?: number = 10): number` — smallest ask order within `depthPct` of the mid-price.

| Parameter  | Type       | Description                      |
| ---------- | ---------- | -------------------------------- |
| `source`   | TimeSeries | Source orderbook data series     |
| `depthPct` | number     | Depth percentage (default: `10`) |

**Returns:** `number` — smallest ask order size within depth.

```javascript
var minAsk = minAskAmount((source = orderbookData), (depthPct = 10));
```

## Best Practices

<table data-view="cards"><tbody>
<tr><td>Depth Analysis</td><td>Use smaller depth percentages (1-5) to focus on top-of-book activity, and larger percentages (10-20) for overall market depth analysis.</td><td></td></tr>
<tr><td>Volume Imbalance</td><td>Significant bid/ask volume imbalances often precede price movements. High bid volume suggests upward pressure; high ask volume suggests downward pressure.</td><td></td></tr>
<tr><td>Large Order Impact</td><td>Monitor maximum order sizes for signs of institutional activity. Sudden appearance of large orders can indicate significant market events.</td><td></td></tr>
</tbody></table>
