Module Trading_engine.Audit

Deterministic audit events emitted by the pure engine.

type cancellation_reason =
  1. | Strategy_requested
  2. | Target_replaced
  3. | Market_ioc
  4. | Immediate_or_cancel
  5. | Fill_or_kill
  6. | Day_expired
  7. | Gtd_expired
  8. | Margin_call
  9. | Borrow_recall
  10. | Instrument_halt
  11. | Instrument_terminal
type target_basis =
  1. | Weights
  2. | Quantities
type requested_target = {
  1. instrument_id : Id.Instrument.t;
  2. weight : Scalar.Weight.t option;
  3. quantity : Scalar.Quantity.t;
  4. reference_price : Scalar.Price.t option;
}
type order_counts = {
  1. total : int;
  2. active : int;
  3. filled : int;
  4. rejected : int;
  5. cancelled : int;
}
type valuation = {
  1. account : Account.valuation;
  2. margin : Risk.margin_snapshot;
}
type event =
  1. | Run_started of {
    1. scenario_sha256 : string;
    2. execution_model : string;
    }
  2. | Initial_state of {
    1. portfolio : Initial_portfolio.t;
    2. valuation : valuation;
    }
  3. | Market_slice_received of Market_slice.t
  4. | Target_portfolio_requested of {
    1. basis : target_basis;
    2. targets : requested_target list;
    }
  5. | Order_accepted of Order.t
  6. | Order_rejected of Order.t
  7. | Order_triggered of Order.t
  8. | Order_cancelled of {
    1. order : Order.t;
    2. reason : cancellation_reason;
    }
  9. | Split_applied of {
    1. action : Corporate_action.t;
    2. previous_quantity : Scalar.Quantity.t;
    3. adjusted_quantity : Scalar.Quantity.t;
    }
  10. | Cash_dividend_applied of {
    1. action : Corporate_action.t;
    2. quantity : Scalar.Quantity.t;
    3. cash_amount : Scalar.Money.t;
    }
  11. | Distribution_applied of {
    1. action : Corporate_action.t;
    2. result : Account.distribution_result;
    }
  12. | Lifecycle_applied of {
    1. lifecycle_event : Instrument_lifecycle.event;
    2. listing : Instrument_lifecycle.listing;
    3. liquidated_quantity : Scalar.Quantity.t;
    4. cash_amount : Scalar.Money.t;
    }
  13. | Order_adjusted of {
    1. order : Order.t;
    2. action_id : Id.Corporate_action.t;
    }
  14. | Execution_price_selected of {
    1. order_id : Id.Order.t;
    2. instrument_id : Id.Instrument.t;
    3. side : Order.side;
    4. attribution : Execution.price_attribution;
    }
  15. | Fill_applied of Fill.t
  16. | Settlement_instruction_created of Settlement.instruction
  17. | Settlement_completed of Settlement.instruction
  18. | Settlement_failed of Settlement.instruction
  19. | Margin_limited of {
    1. order_id : Id.Order.t;
    2. instrument_id : Id.Instrument.t;
    3. requested_quantity : Scalar.Quantity.t;
    4. permitted_quantity : Scalar.Quantity.t;
    5. price : Scalar.Price.t;
    }
  20. | Fill_clipped of {
    1. order_id : Id.Order.t;
    2. instrument_id : Id.Instrument.t;
    3. proposed_quantity : Scalar.Quantity.t;
    4. permitted_quantity : Scalar.Quantity.t;
    5. price : Scalar.Price.t;
    6. limit : Risk.fill_limit;
    }
  21. | Borrow_fee_applied of {
    1. instrument_id : Id.Instrument.t;
    2. quote_currency : string;
    3. short_quantity : Scalar.Quantity.t;
    4. reference_price : Scalar.Price.t;
    5. borrow_bps : int;
    6. period_start : Ptime.t;
    7. period_end : Ptime.t;
    8. fee : Scalar.Money.t;
    }
  22. | Borrow_charge_applied of {
    1. observation : Financing.borrow_observation;
    2. quote_currency : string;
    3. short_quantity : Scalar.Quantity.t;
    4. reference_price : Scalar.Price.t;
    5. day_count : Financing.day_count;
    6. compounding : Financing.compounding;
    7. period_start : Ptime.t;
    8. period_end : Ptime.t;
    9. amount : Scalar.Money.t;
    }
  23. | Borrow_recall_received of {
    1. observation : Financing.borrow_observation;
    2. short_quantity : Scalar.Quantity.t;
    3. close_out_quantity : Scalar.Quantity.t;
    }
  24. | Cash_interest_applied of {
    1. observation : Financing.cash_rate_observation;
    2. opening_balance : Scalar.Money.t;
    3. applied_rate_bps : int;
    4. day_count : Financing.day_count;
    5. compounding : Financing.compounding;
    6. period_start : Ptime.t;
    7. period_end : Ptime.t;
    8. amount : Scalar.Money.t;
    9. closing_balance : Scalar.Money.t;
    }
  25. | Margin_call_triggered of valuation
  26. | Margin_restored of valuation
  27. | Intent_rejected of string
  28. | Metric_emitted of Metric.t
  29. | Valuation of valuation
  30. | Run_completed of {
    1. scenario_sha256 : string;
    2. execution_model : string;
    3. valuation : valuation;
    4. order_counts : order_counts;
    }
type t = private {
  1. contract_version : string;
  2. engine_sequence : int64;
  3. event_id : Id.Event.t;
  4. causation_ids : Id.Event.t list;
  5. run_id : Id.Run.t;
  6. recorded_at : Ptime.t;
  7. event : event;
}
val event_id : run_id:Id.Run.t -> engine_sequence:int64 -> Id.Event.t
val create : contract_version:string -> engine_sequence:int64 -> causation_ids:Id.Event.t list -> run_id:Id.Run.t -> recorded_at:Ptime.t -> event -> t
val cancellation_reason_to_string : cancellation_reason -> string
val target_basis_to_string : target_basis -> string
val event_name : event -> string