# Liquidity-Wall and Concentration Detection

`D11-F05-A06` · Market Microstructure → Market-Depth Analytics · archetype `record-transform` · difficulty 4/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/market-microstructure/market-depth-analytics/liquidity-wall-and-concentration-detection/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { liquidityWallConcentration } from "fintech-algorithms/market-microstructure/market-depth-analytics/liquidity-wall-and-concentration-detection";
```

## Signature

```ts
liquidityWallConcentration(levelsRaw, multipleRaw, minShareRaw, thresholdRaw)
```

Finds levels holding disproportionate size — the 'walls' that act as short-term barriers. Worth treating with suspicion: a wall that disappears the moment price approaches it was never liquidity.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `levelsRaw` | `Level[]` | yes | Book levels to examine. |
| `multipleRaw` | `number` | yes | How many times the average level size counts as a wall. · min: 0 |
| `minShareRaw` | `number` | yes | Minimum share of total depth a level must hold. · min: 0, max: 1 |
| `thresholdRaw` | `number` | yes | Concentration threshold above which the book is flagged as concentrated. · min: 0 |

## Returns

`{ walls, concentration, flagged, … }`

Detected walls with the concentration measure for the book as a whole.

## Errors

- When minShareRaw falls outside 0…1 — throws

## Complexity

Time `O(levels)`, space `O(walls)`.

## Worked example

Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

### Input

`levelsRaw`:

```json
[
  {
    "price": 100.01,
    "quantity": 100
  },
  {
    "price": 100.02,
    "quantity": 110
  },
  {
    "price": 100.03,
    "quantity": 450
  }
]
```

Showing 3 of 5 elements.

`multipleRaw`:

```json
2.5
```

`minShareRaw`:

```json
0.3
```

`thresholdRaw`:

```json
0.3
```

### Call

```ts
liquidityWallConcentration(levelsRaw, multipleRaw, minShareRaw, thresholdRaw)
```

### Returns

object with 13 fields: model, level_count, total_depth, median_level_quantity, hhi_fraction, effective_level_count, largest_level_index, largest_level_share, …

```json
{
  "model": "level-share-concentration-and-wall-screen",
  "level_count": 5,
  "total_depth": 900,
  "median_level_quantity": 120,
  "hhi_fraction": 0.3128395061728395,
  "effective_level_count": 3.196527229676401,
  "largest_level_index": 2,
  "largest_level_share": 0.5,
  "walls": [
    {
      "level_index": 2,
      "price": 100.03,
      "quantity": 450,
      "depth_share": 0.5,
      "median_multiple": 3.75
    }
  ],
  "wall_multiple": 2.5,
  "minimum_share": 0.3,
  "concentration_threshold": 0.3,
  "state": "wall-detected"
}
```

## Other exports

`cumulativeDepth`, `topNDepthImbalance`, `depthAtDistanceProfile`, `expectedFillPrice`, `sweepCostAndSlippage`, `depthDepletionReplenishment`, `marketDepthHeatmap`, `calculate`. Every module additionally exports `run` as an alias of its primary
function, and a `meta` object carrying its catalog id, domain, family, shape and article URL.

## Verification and provenance

Tier: **verified** (via D).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.13.1.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/market-microstructure/market-depth-analytics/liquidity-wall-and-concentration-detection/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-microstructure/market-depth-analytics/liquidity-wall-and-concentration-detection/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-microstructure/llms.txt
