fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

State and Regime Models

6 algorithms in Statistical Time Series · 6 with asserted arithmetic.

In this family#

  1. Kalman Filter verified

    Optimal recursive estimation of a hidden state from noisy observations in a linear Gaussian system. In markets the hidden state is often the thing you actually want — a fair value, a slowly moving beta — and the observation is a noisy proxy for it.

    runFilter(observations, config)
  2. Extended Kalman Filter verified

    The Kalman filter for non-linear systems, linearised at each step. The approximation is local, so strong non-linearity can make it diverge — quietly, while still producing plausible-looking numbers.

    runFilter(observations, config)
  3. Unscented Kalman Filter verified

    Propagates a set of deterministically chosen sigma points through the non-linearity instead of linearising it. More robust than the extended filter for the same cost order, and the usual answer when the EKF diverges.

    runFilter(observations, config)
  4. Hidden Markov Model verified

    Infers a discrete hidden regime from observations. Where the Kalman filter tracks a continuous state, this asks which of a small number of *regimes* the market is in — and returns a probability rather than a label.

    runFilter(observations, config)
  5. Markov-Switching Autoregression verified

    An autoregression whose coefficients switch with a hidden regime. Captures the common situation where a series is persistent in calm conditions and mean-reverting in stressed ones — one AR fit across both describes neither.

    runFilter(observations, config)
  6. Bayesian Change-Point Detection verified

    Online detection of structural breaks by tracking the posterior over run length — how long since the last change. Unlike a regime model it does not need the number of regimes specified in advance.

    runFilter(observations, config)

What they share#

Every topic here is a record-transform, so once you have called one the rest follow the same shape. Import paths differ only in the final segment:

ts
import { runFilter } from "fintech-algorithms/statistical-time-series/state-and-regime-models/kalman-filter";
import { runFilter } from "fintech-algorithms/statistical-time-series/state-and-regime-models/extended-kalman-filter";

Read them in the order above — the sequence is pedagogical, not alphabetical.

Where this sits#

Statistical Time Series collects 29 algorithms across 5 families. For the concept behind this family rather than the call signatures, see the concept guides.