Fix trade setup generation, M5 data-only mode, WS symbol limits, command menu
- Trade setup TP now scales to SL distance ensuring min RR is met when no viable swing target exists; skip swing targets with poor RR - Add float tolerance to RR gate to prevent edge-case rejection - M5 auto-scan runs for level cache only, no Telegram broadcast - WebSocket limited to EUR/USD + XAU/USD (Grow plan constraint) - Register bot command menu via set_my_commands on startup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-9
@@ -470,19 +470,22 @@ class SignalAggregator:
|
||||
if price - sl_price < atr * 1.5:
|
||||
sl_price = price - atr * 1.5
|
||||
|
||||
sl_distance = price - sl_price
|
||||
|
||||
swing_highs = sorted(
|
||||
v for k, v in levels.items() if k.startswith("swing_high_") and v > price + atr * 0.3
|
||||
)
|
||||
if swing_highs and swing_highs[0] - price <= atr * tp_swing_cap:
|
||||
if (swing_highs
|
||||
and swing_highs[0] - price <= atr * tp_swing_cap
|
||||
and swing_highs[0] - price >= sl_distance * min_rr):
|
||||
tp1 = swing_highs[0]
|
||||
else:
|
||||
tp1 = price + atr * tp_mult
|
||||
tp1 = price + max(atr * tp_mult, sl_distance * min_rr)
|
||||
if len(swing_highs) >= 2 and swing_highs[1] - price <= atr * 5.0:
|
||||
tp2 = swing_highs[1]
|
||||
else:
|
||||
tp2 = price + atr * (tp_mult + 1.5)
|
||||
tp2 = price + max(atr * (tp_mult + 1.5), sl_distance * min_rr * 1.5)
|
||||
|
||||
sl_distance = price - sl_price
|
||||
direction = "BUY"
|
||||
entry, sl = price, sl_price
|
||||
else:
|
||||
@@ -496,27 +499,30 @@ class SignalAggregator:
|
||||
if sl_price - price < atr * 1.5:
|
||||
sl_price = price + atr * 1.5
|
||||
|
||||
sl_distance = sl_price - price
|
||||
|
||||
swing_lows = sorted(
|
||||
[v for k, v in levels.items() if k.startswith("swing_low_") and v < price - atr * 0.3],
|
||||
reverse=True,
|
||||
)
|
||||
if swing_lows and price - swing_lows[0] <= atr * tp_swing_cap:
|
||||
if (swing_lows
|
||||
and price - swing_lows[0] <= atr * tp_swing_cap
|
||||
and price - swing_lows[0] >= sl_distance * min_rr):
|
||||
tp1 = swing_lows[0]
|
||||
else:
|
||||
tp1 = price - atr * tp_mult
|
||||
tp1 = price - max(atr * tp_mult, sl_distance * min_rr)
|
||||
if len(swing_lows) >= 2 and price - swing_lows[1] <= atr * 5.0:
|
||||
tp2 = swing_lows[1]
|
||||
else:
|
||||
tp2 = price - atr * (tp_mult + 1.5)
|
||||
tp2 = price - max(atr * (tp_mult + 1.5), sl_distance * min_rr * 1.5)
|
||||
|
||||
sl_distance = sl_price - price
|
||||
direction = "SELL"
|
||||
entry, sl = price, sl_price
|
||||
|
||||
tp1_distance = abs(tp1 - entry)
|
||||
rr = tp1_distance / sl_distance if sl_distance > 0 else 0
|
||||
|
||||
if rr < min_rr:
|
||||
if rr < min_rr - 1e-9:
|
||||
return None
|
||||
|
||||
risk_pips = sl_distance / pip_value
|
||||
|
||||
Reference in New Issue
Block a user