fintech-algorithms

Provider Adjustment-Basis Drift Detector

Install and import

bash
npm install fintech-algorithms
ts
import { detectAdjustmentBasisDrift } from "fintech-algorithms/market-data-engineering/data-quality/provider-adjustment-basis-drift-detector";

Signature

detectAdjustmentBasisDrift(input)

Compares archived provider adjustment factors and isolates unexplained residual drift after newly knowable corporate actions.

Parameters

NameTypeNotes
inputobjectTopic-specific point-in-time audit contract.

Returns

object

Structured state, audit rows, diagnostics, and provenance.

Complexity: time O(n log n), 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

input
{
  "provider": "synthetic-provider",
  "dataset": "daily-equity-bars",
  "instrument_id": "SYNTH-ABC",
  "price_field": "close",
  "basis_id": "split-adjusted-v1",
  "baseline_observed_at": "2026-06-12T20:00:00Z",
  "candidate_observed_at": "2026-06-16T20:00:00Z",
  "tolerance_bps": 1,
  "baseline_rows": [
    {
      "date": "2026-06-10",
      "raw_price": 100,
      "adjusted_price": 100
    },
    {
      "date": "2026-06-11",
      "raw_price": 102,
      "adjusted_price": 102
    },
    {
      "date": "2026-06-12",
      "raw_price": 104,
      "adjusted_price": 104
    }
  ],
  "candidate_rows": [
    {
      "date": "2026-06-10",
      "raw_price": 100,
      "adjusted_price": 50
    },
    {
      "date": "2026-06-11",
      "raw_price": 102,
      "adjusted_price": 51
    },
    {
      "date": "2026-06-12",
      "raw_price": 104,
      "adjusted_price": 52.26
    }
  ],
  "actions": [
    {
      "event_id": "SPLIT-2FOR1",
      "effective_date": "2026-06-15",
      "available_at": "2026-06-13T12:00:00Z",
      "status": "confirmed",
      "adjustment_multiplier": 0.5
    }
  ]
}

Call

detectAdjustmentBasisDrift(input)

Returns

object with 17 fields: provider, dataset, instrument_id, price_field, basis_id, baseline_observed_at, candidate_observed_at, tolerance_bps, …

{
  "provider": "synthetic-provider",
  "dataset": "daily-equity-bars",
  "instrument_id": "SYNTH-ABC",
  "price_field": "close",
  "basis_id": "split-adjusted-v1",
  "baseline_observed_at": "2026-06-12T20:00:00Z",
  "candidate_observed_at": "2026-06-16T20:00:00Z",
  "tolerance_bps": 1,
  "state": "basis-drift",
  "overlap_count": 3,
  "stable_count": 0,
  "expected_restatement_count": 2,
  "drift_count": 1,
  "max_residual_bps": 49.875415
}

Showing 14 of 17 fields.

Diagrams

Provider Adjustment-Basis Drift Detector — system map

Calculation flow

Provider adjustment-basis drift calculation flow
flowchart LR
    A["Archive two matching provider snapshots"] --> B["Compute adjusted/raw factor by shared date"]
    C["Select actions newly knowable between snapshots"] --> D["Build expected multiplier for pre-effective dates"]
    B --> E["Observed factor multiplier"]
    D --> F["Log residual in basis points"]
    E --> F
    F --> G{"Residual ≤ tolerance?"}
    G -->|Yes, no expected action| H["Stable"]
    G -->|Yes, expected action| I["Expected restatement"]
    G -->|No| J["Basis drift"]
    J --> K["Audit invariant: counts sum to overlap and unmatched dates remain visible"]

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

  • Alpha Vantage API documentation
  • Alpha Vantage support: adjustment method
  • Massive Stocks Splits API
  • Massive Stocks flat-file overview
  • Publication decision