Module Algostream_normalization.Data_break

Corporate actions / data discontinuities.

Generalizes splits, dividends, symbol changes, forks, and trading halts into a single variant. v1 only populates Symbol_change and Halt from JSON config (sufficient for crypto). Split / Dividend / Fork are wired and ready for equities + future crypto forks.

type t =
  1. | Split of {
    1. ratio : float;
    }
  2. | Dividend of {
    1. amount : float;
    2. currency : string;
    }
  3. | Symbol_change of {
    1. from_ : string;
    2. to_ : string;
    }
  4. | Fork of {
    1. parent : string;
    2. children : (string * float) list;
    }
  5. | Halt of {
    1. until_ns : int64;
    }
type entry = {
  1. effective_at_ns : int64;
  2. break_ : t;
  3. source : string;
}
type tick = {
  1. symbol : string;
  2. ts_ns : int64;
  3. price : float;
  4. size : float;
}

Simplified Tick value for apply — narrower than the full Tick.tick to keep the data_break layer testable in isolation.

type verdict =
  1. | Pass
  2. | Rewrite of tick
  3. | Drop
  4. | Emit_synthetic of tick list
val apply : entry list -> tick -> verdict

Apply the relevant (effective-at <= tick.ts) entries to a tick. The list is expected to be sorted by effective_at_ns.

val load_file : string -> (entry list, string) Stdlib.result