summaryrefslogtreecommitdiff
path: root/services/strategy-engine/strategies/grid_strategy.py
diff options
context:
space:
mode:
Diffstat (limited to 'services/strategy-engine/strategies/grid_strategy.py')
-rw-r--r--services/strategy-engine/strategies/grid_strategy.py11
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)
)