Fix trade setup generation broken by TP tightening factor

The TP floor calculations used raw min_rr (0.4) but after 20% tightening
the effective RR dropped to ~0.32, failing the min_rr check and returning
None for all trade setups. Pre-compensate the floor with min_rr/tf so
post-tightening RR still meets the minimum.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
harwinder
2026-05-24 18:22:57 -04:00
parent a731b7c8df
commit 998f5e8616
+8 -6
View File
@@ -867,6 +867,8 @@ class SignalAggregator:
is_buy = report.final_score >= 0
levels = report.primary_analysis.key_levels
min_rr = self.config.signals.min_rr_ratio
tf = self.config.signals.tp_tightening_factor
pre_tight_min_rr = min_rr / tf if tf > 0 else min_rr
mature_move = abs(report.final_score) > 30
tp_mult = 1.0 if mature_move else 1.5
@@ -896,14 +898,14 @@ class SignalAggregator:
)
if (swing_highs
and swing_highs[0] - price <= atr * tp_swing_cap
and swing_highs[0] - price >= sl_distance * min_rr):
and swing_highs[0] - price >= sl_distance * pre_tight_min_rr):
tp1 = swing_highs[0]
else:
tp1 = price + max(atr * tp_mult, sl_distance * min_rr)
tp1 = price + max(atr * tp_mult, sl_distance * pre_tight_min_rr)
if len(swing_highs) >= 2 and swing_highs[1] - price <= atr * 5.0:
tp2 = swing_highs[1]
else:
tp2 = price + max(atr * (tp_mult + 1.5), sl_distance * min_rr * 1.5)
tp2 = price + max(atr * (tp_mult + 1.5), sl_distance * pre_tight_min_rr * 1.5)
direction = "BUY"
entry, sl = price, sl_price
@@ -927,14 +929,14 @@ class SignalAggregator:
)
if (swing_lows
and price - swing_lows[0] <= atr * tp_swing_cap
and price - swing_lows[0] >= sl_distance * min_rr):
and price - swing_lows[0] >= sl_distance * pre_tight_min_rr):
tp1 = swing_lows[0]
else:
tp1 = price - max(atr * tp_mult, sl_distance * min_rr)
tp1 = price - max(atr * tp_mult, sl_distance * pre_tight_min_rr)
if len(swing_lows) >= 2 and price - swing_lows[1] <= atr * 5.0:
tp2 = swing_lows[1]
else:
tp2 = price - max(atr * (tp_mult + 1.5), sl_distance * min_rr * 1.5)
tp2 = price - max(atr * (tp_mult + 1.5), sl_distance * pre_tight_min_rr * 1.5)
direction = "SELL"
entry, sl = price, sl_price