Module Algostream_order_management.Execution_quality

Post-trade execution quality (TCA) report.

Wraps and extends Algostream_domain_trades.Trade.Trade_aggregation.execution_quality, which already computes slippage and implementation shortfall for a single trade. This module aggregates a list of fills for the same order into one report with timing metrics, fill rate, VWAP comparison, and IS in basis points.

type fill = {
  1. ts_ns : int64;
  2. price : float;
  3. quantity : float;
  4. venue : string;
  5. commission : float;
}
type report = {
  1. decision_price : float;
  2. total_quantity : float;
  3. filled_quantity : float;
  4. fill_rate : float;
  5. avg_fill_price : float;
  6. total_commission : float;
  7. slippage_bps : float;
    (*

    signed: positive = adverse to the order side

    *)
  8. vwap_diff_bps : float;
    (*

    signed: positive = adverse vs market VWAP over the fill window

    *)
  9. implementation_shortfall_bps : float;
    (*

    |slippage| + commission_bps

    *)
  10. time_to_full_fill_ns : int64 option;
    (*

    Some t iff fill_rate = 1.0

    *)
  11. first_fill_latency_ns : int64;
    (*

    time from decision_ts_ns to the first fill

    *)
}
val analyze : order:Order.order -> decision_price:float -> decision_ts_ns:int64 -> fills:fill list -> market_vwap:float -> report
val report_to_string : report -> string