# Kyle Lambda

`D11-F03-A03` · Market Microstructure → Order-Flow and Impact · archetype `record-transform` · difficulty 4/5 · verification **contract**

Full page: https://docs.thefintechbuilder.com/market-microstructure/order-flow-and-impact/kyle-lambda/
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 { kyleLambda } from "fintech-algorithms/market-microstructure/order-flow-and-impact/kyle-lambda";
```

## Signature

```ts
kyleLambda(inputRows, volumeTransform, intercept)
```

The price-impact coefficient from regressing price change on signed order flow. Lambda *is* the illiquidity parameter in Kyle's model — higher means each unit of flow moves price more.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `inputRows` | `Row[]` | yes | Interval observations of price change and signed volume. |
| `volumeTransform` | `string` | yes | How signed volume enters the regression — raw, or square-rooted for the concave impact many studies find. |
| `intercept` | `boolean` | yes | Whether to fit an intercept. Theory says zero; fitting one and finding it non-zero is diagnostic. |

## Returns

`{ lambda, r_squared, intercept, observations, … }`

The coefficient with its fit quality — a lambda from a regression that explains nothing is a number, not a measurement.

## Errors

- When fewer than two observations, or zero variance in signed volume — throws

## Complexity

Time `O(n)`, 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

`inputRows`:

```json
[
  {
    "id": "K001",
    "interval_end": 0,
    "signed_volume_k": -8.8,
    "mid_change_bps": -3.756
  },
  {
    "id": "K002",
    "interval_end": 1,
    "signed_volume_k": 4.8,
    "mid_change_bps": 2.196
  },
  {
    "id": "K003",
    "interval_end": 2,
    "signed_volume_k": 0,
    "mid_change_bps": 0.08
  }
]
```

Showing 3 of 60 elements.

`volumeTransform`:

```json
"linear"
```

`intercept`:

```json
true
```

### Call

```ts
kyleLambda(inputRows, volumeTransform, intercept)
```

### Returns

object with 10 fields: model, state, volume_transform, intercept, observation_count, alpha_bps, lambda_bps_per_regressor_unit, r_squared, …

```json
{
  "model": "empirical-kyle-lambda",
  "state": "estimated",
  "volume_transform": "linear",
  "intercept": true,
  "observation_count": 60,
  "alpha_bps": 0.1008250803,
  "lambda_bps_per_regressor_unit": 0.4210091524,
  "r_squared": 0.9980824794,
  "residual_std_bps": 0.1004292969,
  "trace": [
    {
      "id": "K001",
      "index": 0,
      "signed_volume_k": -8.8,
      "regressor": -8.8,
      "mid_change_bps": -3.756,
      "predicted_change_bps": -3.6040554607,
      "residual_bps": -0.1519445393,
      "side": "negative-impact",
      "reason": "linear"
    },
    {
      "id": "K002",
      "index": 1,
      "signed_volume_k": 4.8,
      "regressor": 4.8,
      "mid_change_bps": 2.196,
      "predicted_change_bps": 2.1216690117,
      "residual_bps": 0.0743309883,
      "side": "positive-impact",
      "reason": "linear"
    },
    {
      "id": "K003",
      "index": 2,
      "signed_volume_k": 0,
      "regressor": 0,
      "mid_change_bps": 0.08,
      "predicted_change_bps": 0.1008250803,
      "residual_bps": -0.0208250803,
      "side": "positive-impact",
      "reason": "linear"
    }
  ]
}
```

## Other exports

`orderFlowImbalance`, `queueImbalance`, `hasbrouckPriceImpact`, `pin`, `vpin`, `runTopic`. 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: **contract**.

The module loads, the entry point is callable and its declared signature matches the compiled code. The example below is real captured output, but no independently published figure asserts the numbers.

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/order-flow-and-impact/kyle-lambda/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/market-microstructure/order-flow-and-impact/kyle-lambda/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/market-microstructure/llms.txt
