From ef7dd2c7f42dc41b86f2507aeb66aa152d2b0a5a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 12 Dec 2025 21:30:48 +0000 Subject: [PATCH] Fix position/price_level type ambiguity in risk module Add explicit type annotations to check_total_exposure and check_order functions for the 'positions' parameter. Both position and price_level types have a 'quantity' field, causing OCaml to infer the wrong type. The explicit annotation ~(positions:position list) resolves the type mismatch error: "This expression has type Types.position list but an expression was expected of type Types.price_level list" --- core/lib/risk/risk.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/risk/risk.ml b/core/lib/risk/risk.ml index 1132360..9d562b9 100644 --- a/core/lib/risk/risk.ml +++ b/core/lib/risk/risk.ml @@ -83,7 +83,7 @@ let check_position_size ~symbol ~current_position ~order_qty ~order_side config Approved (** Check total exposure *) -let check_total_exposure ~positions ~order_value config = +let check_total_exposure ~(positions:position list) ~order_value config = let total_exposure = List.fold_left (fun acc pos -> Decimal.(acc + Decimal.abs pos.quantity) ) Decimal.zero positions in @@ -131,7 +131,7 @@ let update_rate_limit t = { t with orders_last_minute = t.orders_last_minute + 1; last_order_time = now } (** Main risk check function *) -let check_order ~(order:order) ~account ~positions ~current_position t = +let check_order ~(order:order) ~account ~(positions:position list) ~current_position t = (* Check circuit breaker first *) if t.circuit_breaker_active then Rejected (Printf.sprintf "Circuit breaker active: %s"