fintech-algorithms

Hawkes Order-Arrival Model

Install and import

bash
npm install fintech-algorithms
ts
import { hawkesOrderArrival } from "fintech-algorithms/market-microstructure/order-book-dynamics/hawkes-order-arrival-model";

Signature

hawkesOrderArrival(eventTimesSeconds, baselineIntensity, excitationJump, decayRate, evaluationTimeSeconds, horizonSeconds)

A self-exciting point process: each arrival raises the probability of the next. It captures order clustering that a Poisson model cannot, which is why order flow looks bursty rather than smooth.

Parameters

NameTypeNotes
eventTimesSecondsnumber[]Arrival times in seconds, ascending.
baselineIntensitynumberBackground arrival rate absent any excitation.
min: 0
excitationJumpnumberIntensity added by each arrival. Above the decay rate the process is explosive and has no stationary distribution.
min: 0
decayRatenumberRate at which excitation fades.
min: 0
evaluationTimeSecondsnumberTime at which the intensity is evaluated.
min: 0
horizonSecondsnumberForecast horizon for expected arrivals.
min: 0

Returns

{ intensity, expected_arrivals, branching_ratio, stationary, … }

Intensity and expected arrivals, plus the branching ratio — at or above 1 the process is non-stationary and the forecast is meaningless.

Errors

  • When event times are not ascending, or decayRate is zero — throws

Complexity: time O(n), space O(1).

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

eventTimesSeconds
[0.2, 0.9, 1.4, 2.7]
baselineIntensity
0.5
excitationJump
0.8
decayRate
1.6
evaluationTimeSeconds
3
horizonSeconds
3.5

Call

hawkesOrderArrival(eventTimesSeconds, baselineIntensity, excitationJump, decayRate, evaluationTimeSeconds, horizonSeconds)

Returns

object with 15 fields: model, event_count, baseline_intensity, excitation_jump, decay_rate, branching_ratio, stationary, expected_cluster_multiplier, …

{
  "model": "univariate-exponential-hawkes",
  "event_count": 4,
  "baseline_intensity": 0.5,
  "excitation_jump": 0.8,
  "decay_rate": 1.6,
  "branching_ratio": 0.5,
  "stationary": true,
  "expected_cluster_multiplier": 2,
  "evaluation_time_seconds": 3,
  "intensity_at_evaluation": 1.0937254434790773,
  "event_intensities": [0.5, 0.7610238356984316, 0.9767487409980575, 0.6595044911371601],
  "horizon_seconds": 3.5,
  "compensator": 3.5832637259446924,
  "log_likelihood": -4.9892938375210205
}

Showing 14 of 15 fields.

Other exports

This module also exports orderBookSlope, depthWeightedMidprice, microprice, orderBookResiliency, 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.

Diagrams

Hawkes Order-Arrival Model — system map

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