fintech-algorithms

Hasbrouck Price Impact

Install and import

bash
npm install fintech-algorithms
ts
import { hasbrouckPriceImpact } from "fintech-algorithms/market-microstructure/order-flow-and-impact/hasbrouck-price-impact";

Signature

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

NameTypeNotes
inputRowsRow[]Trades with signed direction and the midpoint path around each.
horizonnumberObservations 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

executed 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
[
  {
    "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
10

Call

hasbrouckPriceImpact(inputRows, horizon)

Returns

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

{
  "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

This module also 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.

Diagrams

Hasbrouck Price Impact — calculation map
Hasbrouck Price Impact — decision boundary
Hasbrouck Price Impact — failure boundary
Hasbrouck Price Impact — scenario matrix
Hasbrouck Price Impact — worked example

How it works

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References