summaryrefslogtreecommitdiff
path: root/services/strategy-engine/strategies/macd_strategy.py
diff options
context:
space:
mode:
Diffstat (limited to 'services/strategy-engine/strategies/macd_strategy.py')
-rw-r--r--services/strategy-engine/strategies/macd_strategy.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/services/strategy-engine/strategies/macd_strategy.py b/services/strategy-engine/strategies/macd_strategy.py
index 049574e..e3bb35c 100644
--- a/services/strategy-engine/strategies/macd_strategy.py
+++ b/services/strategy-engine/strategies/macd_strategy.py
@@ -28,6 +28,20 @@ class MacdStrategy(BaseStrategy):
self._signal_period = int(params.get("signal_period", 9))
self._quantity = Decimal(str(params.get("quantity", "0.01")))
+ if self._fast_period >= self._slow_period:
+ raise ValueError(
+ f"MACD fast_period must be < slow_period, "
+ f"got fast={self._fast_period}, slow={self._slow_period}"
+ )
+ if self._fast_period < 2:
+ raise ValueError(f"MACD fast_period must be >= 2, got {self._fast_period}")
+ if self._slow_period < 2:
+ raise ValueError(f"MACD slow_period must be >= 2, got {self._slow_period}")
+ if self._signal_period < 2:
+ raise ValueError(f"MACD signal_period must be >= 2, got {self._signal_period}")
+ if self._quantity <= 0:
+ raise ValueError(f"Quantity must be positive, got {self._quantity}")
+
def reset(self) -> None:
self._closes.clear()
self._prev_histogram = None