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/rsi_strategy.py | |
| parent | adf5e96542ebd65c7d13ca5e9825071183b3ef13 (diff) | |
feat(strategy): add parameter validation to all strategies
Diffstat (limited to 'services/strategy-engine/strategies/rsi_strategy.py')
| -rw-r--r-- | services/strategy-engine/strategies/rsi_strategy.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/services/strategy-engine/strategies/rsi_strategy.py b/services/strategy-engine/strategies/rsi_strategy.py index c37957d..59946f4 100644 --- a/services/strategy-engine/strategies/rsi_strategy.py +++ b/services/strategy-engine/strategies/rsi_strategy.py @@ -44,6 +44,16 @@ class RsiStrategy(BaseStrategy): self._overbought = float(params.get("overbought", 70)) self._quantity = Decimal(str(params.get("quantity", "0.01"))) + if self._period < 2: + raise ValueError(f"RSI period must be >= 2, got {self._period}") + if not (0 < self._oversold < self._overbought < 100): + raise ValueError( + f"RSI thresholds must be 0 < oversold < overbought < 100, " + f"got oversold={self._oversold}, overbought={self._overbought}" + ) + if self._quantity <= 0: + raise ValueError(f"Quantity must be positive, got {self._quantity}") + def reset(self) -> None: self._closes.clear() |
