# Hasbrouck Price Impact

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

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

## Signature

```ts
hasbrouckPriceImpact(inputRows, horizon)
```

Decomposes a trade's price effect into the permanent part — information — and the transient part that reverts. The split is what distinguishes an informed trade from a liquidity demand.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `inputRows` | `Row[]` | yes | Trades with signed direction and the midpoint path around each. |
| `horizon` | `number` | yes | Observations after the trade over which permanence is judged. · min: 1, integer: true |

## Returns

`{ permanent_impact, transient_impact, total, horizon, … }`

Both components with the horizon they were measured over.

## Errors

- When the midpoint path is shorter than the horizon — throws

## Complexity

Time `O(n × horizon)`, space `O(n)`.

## 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": "H001",
    "interval_end": 0,
    "signed_flow": -1.8,
    "mid_change_bps": -0.404
  },
  {
    "id": "H002",
    "interval_end": 1,
    "signed_flow": 0.17,
    "mid_change_bps": -0.43029818
  },
  {
    "id": "H003",
    "interval_end": 2,
    "signed_flow": -0.3405,
    "mid_change_bps": -0.03967215
  }
]
```

Showing 3 of 60 elements.

`horizon`:

```json
10
```

### Call

```ts
hasbrouckPriceImpact(inputRows, horizon)
```

### Returns

object with 11 fields: model, state, observation_count, horizon, flow_equation, return_equation, flow_innovation_variance, return_flow_innovation_covariance, …

```json
{
  "model": "hasbrouck-var1-flow-first",
  "state": "estimated",
  "observation_count": 60,
  "horizon": 10,
  "flow_equation": {
    "intercept": -0.0138732152,
    "flow_lag": 0.0401141764,
    "return_lag": -0.7889548599
  },
  "return_equation": {
    "intercept": -0.0042458851,
    "flow_lag": 0.232390819,
    "return_lag": -0.0460365216
  },
  "flow_innovation_variance": 0.9887794778,
  "return_flow_innovation_covariance": 0.1786454708,
  "contemporaneous_return_response_bps": 0.1806727129,
  "cumulative_price_impact_bps": 0.3417920234,
  "trace": [
    {
      "id": "H000",
      "index": 0,
      "flow_response": 1,
      "return_response_bps": 0.1806727129,
      "cumulative_impact_bps": 0.1806727129,
      "side": "positive-impact",
      "reason": "recursive-var1-response"
    },
    {
      "id": "H001",
      "index": 1,
      "flow_response": -0.1024284385,
      "return_response_bps": 0.2240732757,
      "cumulative_impact_bps": 0.4047459887,
      "side": "positive-impact",
      "reason": "recursive-var1-response"
    },
    {
      "id": "H002",
      "index": 2,
      "flow_response": -0.1808925323,
      "return_response_bps": -0.0341189829,
      "cumulative_impact_bps": 0.3706270058,
      "side": "positive-impact",
      "reason": "recursive-var1-response"
    }
  ]
}
```

## Other exports

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