From 76f934f95d3b5cbb96765e7158976e4a4c879fa9 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Wed, 1 Apr 2026 17:11:10 +0900 Subject: feat(strategy): add parameter validation to all strategies --- services/strategy-engine/strategies/grid_strategy.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'services/strategy-engine/strategies/grid_strategy.py') diff --git a/services/strategy-engine/strategies/grid_strategy.py b/services/strategy-engine/strategies/grid_strategy.py index 78e2703..b65264c 100644 --- a/services/strategy-engine/strategies/grid_strategy.py +++ b/services/strategy-engine/strategies/grid_strategy.py @@ -27,6 +27,17 @@ class GridStrategy(BaseStrategy): self._upper_price = float(params["upper_price"]) self._grid_count = int(params.get("grid_count", 5)) self._quantity = Decimal(str(params.get("quantity", "0.01"))) + + if self._lower_price >= self._upper_price: + raise ValueError( + f"Grid lower_price must be < upper_price, " + f"got lower={self._lower_price}, upper={self._upper_price}" + ) + if self._grid_count < 2: + raise ValueError(f"Grid grid_count must be >= 2, got {self._grid_count}") + if self._quantity <= 0: + raise ValueError(f"Quantity must be positive, got {self._quantity}") + self._grid_levels = list( np.linspace(self._lower_price, self._upper_price, self._grid_count + 1) ) -- cgit v1.2.3