diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-01 17:11:10 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-01 17:11:10 +0900 |
| commit | 76f934f95d3b5cbb96765e7158976e4a4c879fa9 (patch) | |
| tree | 4dc93becf70e41e9df9cc7bb777c6defc3a85d30 /services/strategy-engine/strategies/grid_strategy.py | |
| parent | adf5e96542ebd65c7d13ca5e9825071183b3ef13 (diff) | |
feat(strategy): add parameter validation to all strategies
Diffstat (limited to 'services/strategy-engine/strategies/grid_strategy.py')
| -rw-r--r-- | services/strategy-engine/strategies/grid_strategy.py | 11 |
1 files changed, 11 insertions, 0 deletions
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) ) |
