# Quoted Spread

`D11-F02-A01` · Market Microstructure → Liquidity and Spreads · archetype `record-transform` · difficulty 2/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/market-microstructure/liquidity-and-spreads/quoted-spread/
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 { quotedSpread } from "fintech-algorithms/market-microstructure/liquidity-and-spreads/quoted-spread";
```

## Signature

```ts
quotedSpread(bid, ask)
```

Ask minus bid — what the book advertises. The upper bound on what a small marketable order costs, and routinely wider than what trades actually pay.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `bid` | `number` | yes | Best bid price. |
| `ask` | `number` | yes | Best ask price; must not be below the bid. |

## Returns

`{ spread, relative_spread, midpoint, … }`

The absolute spread with its relative form in basis points, which is the comparable one across instruments.

## Errors

- When ask is below bid, or either is not positive — throws

## Complexity

Time `O(1)`, space `O(1)`.

## 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

`bid`:

```json
100
```

`ask`:

```json
100.08
```

### Call

```ts
quotedSpread(bid, ask)
```

### Returns

object with 8 fields: model, bid, ask, midpoint, quoted_spread, quoted_spread_relative, quoted_spread_bps, state

```json
{
  "model": "quoted-spread",
  "bid": 100,
  "ask": 100.08,
  "midpoint": 100.03999999999999,
  "quoted_spread": 0.0799999999999983,
  "quoted_spread_relative": 0.0007996801279488034,
  "quoted_spread_bps": 7.996801279488034,
  "state": "two-sided"
}
```

## Other exports

`effectiveSpread`, `realizedSpread`, `rollSpread`, `amihudIlliquidity`, `corwinSchultzSpread`, `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/liquidity-and-spreads/quoted-spread/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-microstructure/liquidity-and-spreads/quoted-spread/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-microstructure/llms.txt
