From cb55c81dbc43df83ef4d5b717fe22b4d04a93d2e Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Wed, 1 Apr 2026 18:44:20 +0900 Subject: feat(strategy): apply filters, conviction scoring, and ATR stops to all strategies --- .../strategies/volume_profile_strategy.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'services/strategy-engine/strategies/volume_profile_strategy.py') diff --git a/services/strategy-engine/strategies/volume_profile_strategy.py b/services/strategy-engine/strategies/volume_profile_strategy.py index 2cfa87a..324f1c2 100644 --- a/services/strategy-engine/strategies/volume_profile_strategy.py +++ b/services/strategy-engine/strategies/volume_profile_strategy.py @@ -43,6 +43,14 @@ class VolumeProfileStrategy(BaseStrategy): if self._quantity <= 0: raise ValueError(f"Quantity must be positive, got {self._quantity}") + self._init_filters( + require_trend=False, + adx_threshold=float(params.get("adx_threshold", 25.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._candles.clear() self._was_below_va = False @@ -106,6 +114,7 @@ class VolumeProfileStrategy(BaseStrategy): return (poc, va_low, va_high) def on_candle(self, candle: Candle) -> Signal | None: + self._update_filter_data(candle) close = float(candle.close) volume = float(candle.volume) self._candles.append((close, volume)) @@ -124,25 +133,29 @@ class VolumeProfileStrategy(BaseStrategy): # BUY: was below VA, price bounces back between va_low and poc if self._was_below_va and va_low <= close <= poc: self._was_below_va = False - return Signal( + signal = Signal( strategy=self.name, symbol=candle.symbol, side=OrderSide.BUY, price=candle.close, quantity=self._quantity, + conviction=0.6, reason=f"Price bounced from below VA low {va_low:.2f} to {close:.2f} (POC {poc:.2f})", ) + return self._apply_filters(signal) # SELL: was above VA, price pulls back between poc and va_high if self._was_above_va and poc <= close <= va_high: self._was_above_va = False - return Signal( + signal = Signal( strategy=self.name, symbol=candle.symbol, side=OrderSide.SELL, price=candle.close, quantity=self._quantity, + conviction=0.6, reason=f"Price rejected from above VA high {va_high:.2f} to {close:.2f} (POC {poc:.2f})", ) + return self._apply_filters(signal) return None -- cgit v1.2.3