summaryrefslogtreecommitdiff
path: root/services/strategy-engine/strategies/ema_crossover_strategy.py
diff options
context:
space:
mode:
Diffstat (limited to 'services/strategy-engine/strategies/ema_crossover_strategy.py')
-rw-r--r--services/strategy-engine/strategies/ema_crossover_strategy.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/services/strategy-engine/strategies/ema_crossover_strategy.py b/services/strategy-engine/strategies/ema_crossover_strategy.py
index 17234a3..b0ccbbf 100644
--- a/services/strategy-engine/strategies/ema_crossover_strategy.py
+++ b/services/strategy-engine/strategies/ema_crossover_strategy.py
@@ -26,6 +26,18 @@ class EmaCrossoverStrategy(BaseStrategy):
self._long_period = int(params.get("long_period", 21))
self._quantity = Decimal(str(params.get("quantity", "0.01")))
+ if self._short_period >= self._long_period:
+ raise ValueError(
+ f"EMA short_period must be < long_period, "
+ f"got short={self._short_period}, long={self._long_period}"
+ )
+ if self._short_period < 2:
+ raise ValueError(f"EMA short_period must be >= 2, got {self._short_period}")
+ if self._long_period < 2:
+ raise ValueError(f"EMA long_period must be >= 2, got {self._long_period}")
+ if self._quantity <= 0:
+ raise ValueError(f"Quantity must be positive, got {self._quantity}")
+
def reset(self) -> None:
self._closes.clear()
self._prev_short_above = None