07.4.4.1.9.6.2 Momentum & Breakout Semantic Engine
This commit is contained in:
@@ -501,6 +501,9 @@ class ExecutionEngine:
|
||||
repeat_count = int(state.last_signal_repeat_count or 0)
|
||||
unrealized_pnl = float(state.unrealized_pnl_usd or 0.0)
|
||||
hold_seconds = self._position_hold_seconds(position)
|
||||
momentum_direction = getattr(state, "momentum_direction", None)
|
||||
momentum_state = getattr(state, "momentum_state", None)
|
||||
signal = (state.last_signal or "").upper()
|
||||
|
||||
if confidence < self._min_flip_confidence:
|
||||
return (
|
||||
@@ -519,6 +522,19 @@ class ExecutionEngine:
|
||||
"позиция открыта слишком недавно "
|
||||
f"({hold_seconds}с < {self._min_flip_hold_seconds}с)"
|
||||
)
|
||||
|
||||
if signal == "BUY" and momentum_direction == "DOWN":
|
||||
return "momentum направлен против BUY сигнала"
|
||||
|
||||
if signal == "SELL" and momentum_direction == "UP":
|
||||
return "momentum направлен против SELL сигнала"
|
||||
|
||||
if momentum_state in {"BREAKOUT_UP", "BREAKOUT_DOWN"}:
|
||||
if confidence < 0.85:
|
||||
return (
|
||||
"flip заблокирован во время breakout impulse "
|
||||
f"({confidence:.2f} < 0.85)"
|
||||
)
|
||||
|
||||
if unrealized_pnl < 0 and confidence < self._loss_flip_confidence:
|
||||
return (
|
||||
@@ -711,6 +727,38 @@ class ExecutionEngine:
|
||||
elif market_phase in {"RANGE", "SQUEEZE"}:
|
||||
multiplier *= 0.7
|
||||
|
||||
momentum_state = getattr(state, "momentum_state", None)
|
||||
momentum_direction = getattr(state, "momentum_direction", None)
|
||||
momentum_strength = getattr(state, "momentum_strength", None)
|
||||
|
||||
signal = (state.last_signal or "").upper()
|
||||
|
||||
if momentum_state in {"BREAKOUT_UP", "BREAKOUT_DOWN"}:
|
||||
multiplier *= 1.15
|
||||
|
||||
elif momentum_state in {"MOMENTUM_UP", "MOMENTUM_DOWN"}:
|
||||
multiplier *= 1.05
|
||||
|
||||
if momentum_strength is not None:
|
||||
try:
|
||||
strength = float(momentum_strength)
|
||||
|
||||
if strength >= 1.5:
|
||||
multiplier *= 1.1
|
||||
elif strength <= 0.7:
|
||||
multiplier *= 0.8
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if signal == "BUY":
|
||||
if momentum_direction == "DOWN":
|
||||
multiplier *= 0.75
|
||||
|
||||
if signal == "SELL":
|
||||
if momentum_direction == "UP":
|
||||
multiplier *= 0.75
|
||||
|
||||
execution_quality = getattr(state, "execution_quality", None)
|
||||
execution_quality_reason = getattr(state, "execution_quality_reason", None)
|
||||
|
||||
@@ -762,6 +810,9 @@ class ExecutionEngine:
|
||||
"market_trend_strength": getattr(state, "market_trend_strength", None),
|
||||
"market_trend_quality": getattr(state, "market_trend_quality", None),
|
||||
"market_phase": getattr(state, "market_phase", None),
|
||||
"momentum_state": getattr(state, "momentum_state", None),
|
||||
"momentum_direction": getattr(state, "momentum_direction", None),
|
||||
"momentum_strength": getattr(state, "momentum_strength", None),
|
||||
"execution_quality": getattr(state, "execution_quality", None),
|
||||
"execution_quality_reason": getattr(state, "execution_quality_reason", None),
|
||||
"spread_percent": getattr(state, "spread_percent", None),
|
||||
|
||||
Reference in New Issue
Block a user