From e318f128260be0e73aaf5394d1a74d97b66efc7b Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 12 Dec 2025 21:42:25 +0000 Subject: [PATCH] Fix OCaml type inference in List.fold_left lambda Add explicit type annotation (pos:position) inside the fold_left lambda. OCaml's type inference determines element type from field access inside lambdas, not from the parameter annotation. Since both position and price_level types have a 'quantity' field, OCaml was inferring price_level based on definition order in types.ml. The fix: annotate the lambda parameter directly: List.fold_left (fun acc (pos:position) -> ...) This ensures OCaml knows pos is of type position when accessing pos.quantity. --- core/lib/risk/risk.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/risk/risk.ml b/core/lib/risk/risk.ml index 9d562b9..746fc83 100644 --- a/core/lib/risk/risk.ml +++ b/core/lib/risk/risk.ml @@ -84,7 +84,7 @@ let check_position_size ~symbol ~current_position ~order_qty ~order_side config (** Check total exposure *) let check_total_exposure ~(positions:position list) ~order_value config = - let total_exposure = List.fold_left (fun acc pos -> + let total_exposure = List.fold_left (fun acc (pos:position) -> Decimal.(acc + Decimal.abs pos.quantity) ) Decimal.zero positions in let new_exposure = Decimal.(total_exposure + order_value) in