diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-01 18:44:20 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-01 18:44:20 +0900 |
| commit | cb55c81dbc43df83ef4d5b717fe22b4d04a93d2e (patch) | |
| tree | 26ef6f6a89233fa8cf74ea6467b07f1158d75ff1 /services/strategy-engine/strategies/grid_strategy.py | |
| parent | 0b0aace94fa633cd7a90c95ee89658167a8afd35 (diff) | |
feat(strategy): apply filters, conviction scoring, and ATR stops to all strategies
Diffstat (limited to 'services/strategy-engine/strategies/grid_strategy.py')
| -rw-r--r-- | services/strategy-engine/strategies/grid_strategy.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/services/strategy-engine/strategies/grid_strategy.py b/services/strategy-engine/strategies/grid_strategy.py index 1244eda..70443ec 100644 --- a/services/strategy-engine/strategies/grid_strategy.py +++ b/services/strategy-engine/strategies/grid_strategy.py @@ -44,6 +44,14 @@ class GridStrategy(BaseStrategy): ) self._last_zone = None + self._init_filters( + require_trend=False, + adx_threshold=float(params.get("adx_threshold", 20.0)), + min_volume_ratio=float(params.get("min_volume_ratio", 0.5)), + atr_stop_multiplier=float(params.get("atr_stop_multiplier", 2.0)), + atr_tp_multiplier=float(params.get("atr_tp_multiplier", 3.0)), + ) + def reset(self) -> None: self._last_zone = None @@ -59,6 +67,7 @@ class GridStrategy(BaseStrategy): return len(self._grid_levels) def on_candle(self, candle: Candle) -> Signal | None: + self._update_filter_data(candle) price = float(candle.close) current_zone = self._get_zone(price) @@ -71,23 +80,27 @@ class GridStrategy(BaseStrategy): if current_zone < prev_zone: # Price moved to a lower zone → BUY - return Signal( + signal = Signal( strategy=self.name, symbol=candle.symbol, side=OrderSide.BUY, price=candle.close, quantity=self._quantity, + conviction=0.5, reason=f"Grid: price crossed down from zone {prev_zone} to {current_zone}", ) + return self._apply_filters(signal) elif current_zone > prev_zone: # Price moved to a higher zone → SELL - return Signal( + signal = Signal( strategy=self.name, symbol=candle.symbol, side=OrderSide.SELL, price=candle.close, quantity=self._quantity, + conviction=0.5, reason=f"Grid: price crossed up from zone {prev_zone} to {current_zone}", ) + return self._apply_filters(signal) return None |
