# Corwin-Schultz Spread Estimator

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

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

## Signature

```ts
corwinSchultzSpread(highDay1, lowDay1, highDay2, lowDay2, clipNegative)
```

Estimates the spread from daily high-low ranges over two days, exploiting that the range reflects both volatility and spread while volatility scales with time and the spread does not. Frequently returns negative values, which are theoretically impossible.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `highDay1` | `number` | yes | First day's high. |
| `lowDay1` | `number` | yes | First day's low. |
| `highDay2` | `number` | yes | Second day's high. |
| `lowDay2` | `number` | yes | Second day's low. |
| `clipNegative` | `boolean` | yes | Whether to clip negative estimates to zero. Corwin and Schultz recommend it; leaving them visible is more honest when averaging across a sample. |

## Returns

`{ spread, raw_spread, beta, gamma, alpha, clipped }`

The estimate with every intermediate, and whether clipping was applied.

## Errors

- When any high is below its low — 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

`highDay1`:

```json
101
```

`lowDay1`:

```json
99
```

`highDay2`:

```json
101.5
```

`lowDay2`:

```json
99.5
```

`clipNegative`:

```json
true
```

### Call

```ts
corwinSchultzSpread(highDay1, lowDay1, highDay2, lowDay2, clipNegative)
```

### Returns

object with 9 fields: model, beta, gamma, alpha_raw, alpha_used, spread_estimate_relative, spread_estimate_bps, clip_negative, …

```json
{
  "model": "corwin-schultz-spread",
  "beta": 0.0007960826118720654,
  "gamma": 0.0006219511446669105,
  "alpha_raw": 0.007908933752463966,
  "alpha_used": 0.007908933752463966,
  "spread_estimate_relative": 0.007908892526591878,
  "spread_estimate_bps": 79.08892526591879,
  "clip_negative": true,
  "state": "estimated"
}
```

## Other exports

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