Module Trading_engine.Strategy

Pure strategy callback contract.

type context
type marked_position = private {
  1. instrument_id : Id.Instrument.t;
  2. quantity : Scalar.Quantity.t;
  3. settled_quantity : Scalar.Quantity.t;
  4. unsettled_quantity : Scalar.Quantity.t;
  5. mark : Scalar.Price.t;
  6. base_market_value : Scalar.Money.t;
  7. weight : Scalar.Weight.t option;
}
type portfolio = private {
  1. base_currency : string;
  2. cash : Scalar.Money.t;
  3. net_market_value : Scalar.Money.t;
  4. long_market_value : Scalar.Money.t;
  5. short_market_value : Scalar.Money.t;
  6. gross_exposure : Scalar.Money.t;
  7. equity : Scalar.Money.t;
  8. cash_weight : Scalar.Weight.t option;
  9. cash_balances : Account.cash_attribution list;
  10. positions : marked_position list;
  11. group_exposures : Risk.group_exposure list;
}
type event =
  1. | Market_slice_closed of Market_slice.t
  2. | Fill_received of Fill.t
  3. | Order_updated of Order.t
  4. | Intent_rejected of string
type weight_target = {
  1. instrument_id : Id.Instrument.t;
  2. weight : Scalar.Weight.t;
}
type quantity_target = {
  1. instrument_id : Id.Instrument.t;
  2. quantity : Scalar.Quantity.t;
}
type intent =
  1. | Target_weights of weight_target list
  2. | Target_quantities of quantity_target list
  3. | Submit_order of Order.request
  4. | Cancel_order of Id.Order.t
  5. | Emit_metric of Metric.t
val context : now:Ptime.t -> valuation:Account.valuation -> group_exposures:Risk.group_exposure list -> working_orders:Order.t list -> latest_bars:Bar.t list -> (context, string) Stdlib.result
val now : context -> Ptime.t
val portfolio : context -> portfolio
val cash : context -> Scalar.Money.t
val cash_balances : context -> (string * Scalar.Money.t) list
val working_orders : context -> Order.t list
val latest_bar : context -> Id.Instrument.t -> Bar.t option
val group_exposures : context -> Risk.group_exposure list
module type S = sig ... end