Module Algostream_reporting.Live_compare

Compare two running strategy instances.

The last open item in strategy management. Everything it needs already existed and was reachable from nothing: Algostream_runtime.Instance.nav_curve had no callers, Algostream_performance.Metrics.of_nav takes exactly its type, Algostream_performance.Benchmark_compare.compare is a ready-made A-versus-B vector, and Algostream_infrastructure_network.Json.of_series serialises the curve. What was missing was the join: two live instances sample on their own timers, so their curves cannot be compared positionally. Algostream_performance.Nav_align supplies the grid; this module puts the pieces together.

Both arms are computed on the aligned grid, so the metrics reported for A here can differ slightly from A's own standalone metrics — a comparison is only meaningful over the window both curves cover, and that window is usually shorter than either curve.

module Benchmark_compare = Algostream_performance.Benchmark_compare
type t = {
  1. a_id : string;
  2. b_id : string;
  3. n_periods : int;
    (*

    points on the aligned grid; 0 when the curves do not overlap

    *)
  4. overlap_ns : int64;
  5. periods_per_year : float;
    (*

    inferred from the grid's median spacing

    *)
  6. a_metrics : Metrics.t;
  7. b_metrics : Metrics.t;
  8. relative : Benchmark_compare.t;
    (*

    B measured against A: A is the benchmark

    *)
  9. a_curve : (int64 * float) array;
    (*

    on the aligned grid, for charting

    *)
  10. b_curve : (int64 * float) array;
}
type error = [
  1. | `Unknown_instance of string
  2. | `Same_instance of string
  3. | `No_overlap
  4. | `Too_short of int
]
val error_to_string : error -> string
val min_periods : int

Minimum aligned points before a comparison is reported at all. Below this, beta, correlation and tracking error are dominated by noise and quoting them would be worse than declining.

val of_supervisor : Algostream_runtime.Supervisor.t -> a_id:string -> b_id:string -> (t, error) Stdlib.result

Compare the two named instances of a supervisor. b is measured against a.

val of_curves : a_id:string -> b_id:string -> a:(int64 * float) array -> b:(int64 * float) array -> (t, error) Stdlib.result

Compare two curves directly. Exposed for testing and for offline use.

val to_json : t -> Yojson.Safe.t