07.4.4.1.9.5 Execution Confidence Engine
This commit is contained in:
@@ -148,6 +148,29 @@ def _execution_semantic_line(state) -> str:
|
|||||||
return str(message)
|
return str(message)
|
||||||
|
|
||||||
|
|
||||||
|
def _execution_confidence_line(state) -> str:
|
||||||
|
signal = (state.last_signal or "HOLD").upper()
|
||||||
|
|
||||||
|
if signal not in {"BUY", "SELL"}:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
score = getattr(state, "execution_confidence_score", None)
|
||||||
|
level = getattr(state, "execution_confidence_level", None)
|
||||||
|
|
||||||
|
if score is None:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
percent = int(round(float(score) * 100))
|
||||||
|
|
||||||
|
if level == "HIGH":
|
||||||
|
return f"🧠 Уверенность входа · {percent}% высокая"
|
||||||
|
|
||||||
|
if level == "NORMAL":
|
||||||
|
return f"🧠 Уверенность входа · {percent}% нормальная"
|
||||||
|
|
||||||
|
return f"🧠 Уверенность входа · {percent}% низкая"
|
||||||
|
|
||||||
|
|
||||||
def _build_waiting_text(state) -> str:
|
def _build_waiting_text(state) -> str:
|
||||||
price = _signal_entry_price(state)
|
price = _signal_entry_price(state)
|
||||||
|
|
||||||
@@ -164,6 +187,7 @@ def _build_waiting_text(state) -> str:
|
|||||||
signal_lines = [
|
signal_lines = [
|
||||||
_signal_line(state),
|
_signal_line(state),
|
||||||
_signal_confirmation_line(state),
|
_signal_confirmation_line(state),
|
||||||
|
_execution_confidence_line(state),
|
||||||
_market_semantic_line(state),
|
_market_semantic_line(state),
|
||||||
_entry_block_line(state),
|
_entry_block_line(state),
|
||||||
_execution_semantic_line(state),
|
_execution_semantic_line(state),
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class AutoTradeService:
|
|||||||
|
|
||||||
# минимальная уверенность для готовности к будущему execution
|
# минимальная уверенность для готовности к будущему execution
|
||||||
_ready_confidence = 0.3
|
_ready_confidence = 0.3
|
||||||
|
# минимальный итоговый execution confidence для допуска входа
|
||||||
|
_execution_confidence_required_score = 0.55
|
||||||
|
|
||||||
_signal_ttl_seconds = 90
|
_signal_ttl_seconds = 90
|
||||||
_market_analysis_ttl_seconds = 180
|
_market_analysis_ttl_seconds = 180
|
||||||
@@ -376,6 +378,14 @@ class AutoTradeService:
|
|||||||
state.execution_semantic_status = None
|
state.execution_semantic_status = None
|
||||||
state.execution_semantic_message = None
|
state.execution_semantic_message = None
|
||||||
state.execution_semantic_reason = None
|
state.execution_semantic_reason = None
|
||||||
|
state.execution_quality = None
|
||||||
|
state.execution_quality_reason = None
|
||||||
|
state.execution_quality_message = None
|
||||||
|
state.execution_confidence_score = None
|
||||||
|
state.execution_confidence_level = None
|
||||||
|
state.execution_confidence_required_score = self._execution_confidence_required_score
|
||||||
|
state.execution_confidence_reason = None
|
||||||
|
state.execution_confidence_factors = None
|
||||||
state.signal_started_at = None
|
state.signal_started_at = None
|
||||||
state.signal_updated_at = None
|
state.signal_updated_at = None
|
||||||
state.market_state = None
|
state.market_state = None
|
||||||
@@ -395,9 +405,6 @@ class AutoTradeService:
|
|||||||
state.runtime_expired_message = None
|
state.runtime_expired_message = None
|
||||||
state.snapshot_age_seconds = None
|
state.snapshot_age_seconds = None
|
||||||
state.spread_percent = None
|
state.spread_percent = None
|
||||||
state.execution_quality = None
|
|
||||||
state.execution_quality_reason = None
|
|
||||||
state.execution_quality_message = None
|
|
||||||
|
|
||||||
# собрать контекст для стратегии
|
# собрать контекст для стратегии
|
||||||
def _build_strategy_context(self) -> StrategyContext:
|
def _build_strategy_context(self) -> StrategyContext:
|
||||||
@@ -515,6 +522,24 @@ class AutoTradeService:
|
|||||||
f"{confidence:.2f} < {self._ready_confidence:.2f}."
|
f"{confidence:.2f} < {self._ready_confidence:.2f}."
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self._sync_execution_confidence_state(
|
||||||
|
state=state,
|
||||||
|
signal=signal,
|
||||||
|
confidence=confidence,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
state.execution_confidence_score is not None
|
||||||
|
and state.execution_confidence_score < self._execution_confidence_required_score
|
||||||
|
):
|
||||||
|
state.decision_status = "BLOCKED"
|
||||||
|
state.decision_reason = (
|
||||||
|
f"Execution confidence низкий: "
|
||||||
|
f"{state.execution_confidence_score:.2f} < "
|
||||||
|
f"{self._execution_confidence_required_score:.2f}."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
state.is_signal_ready = True
|
state.is_signal_ready = True
|
||||||
state.signal_confirmation_progress = 1.0
|
state.signal_confirmation_progress = 1.0
|
||||||
@@ -1271,6 +1296,140 @@ class AutoTradeService:
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _sync_execution_confidence_state(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
state: AutoTradeState,
|
||||||
|
signal: str,
|
||||||
|
confidence: float,
|
||||||
|
) -> None:
|
||||||
|
if signal not in {"BUY", "SELL"}:
|
||||||
|
state.execution_confidence_score = None
|
||||||
|
state.execution_confidence_level = None
|
||||||
|
state.execution_confidence_required_score = self._execution_confidence_required_score
|
||||||
|
state.execution_confidence_reason = None
|
||||||
|
state.execution_confidence_factors = None
|
||||||
|
return
|
||||||
|
|
||||||
|
signal_score = self._clamp_score(confidence)
|
||||||
|
confirmation_score = self._clamp_score(state.signal_confirmation_progress)
|
||||||
|
market_score = self._market_confidence_score(state)
|
||||||
|
execution_score = self._execution_quality_confidence_score(state)
|
||||||
|
|
||||||
|
score = (
|
||||||
|
signal_score * 0.35
|
||||||
|
+ confirmation_score * 0.20
|
||||||
|
+ market_score * 0.25
|
||||||
|
+ execution_score * 0.20
|
||||||
|
)
|
||||||
|
|
||||||
|
score = round(self._clamp_score(score), 3)
|
||||||
|
|
||||||
|
state.execution_confidence_score = score
|
||||||
|
state.execution_confidence_required_score = self._execution_confidence_required_score
|
||||||
|
state.execution_confidence_level = self._execution_confidence_level(score)
|
||||||
|
state.execution_confidence_reason = self._execution_confidence_reason(state)
|
||||||
|
state.execution_confidence_factors = {
|
||||||
|
"signal_score": round(signal_score, 3),
|
||||||
|
"confirmation_score": round(confirmation_score, 3),
|
||||||
|
"market_score": round(market_score, 3),
|
||||||
|
"execution_score": round(execution_score, 3),
|
||||||
|
"required_score": self._execution_confidence_required_score,
|
||||||
|
"market_state": state.market_state,
|
||||||
|
"market_trend": state.market_trend,
|
||||||
|
"market_trend_strength": state.market_trend_strength,
|
||||||
|
"market_trend_quality": state.market_trend_quality,
|
||||||
|
"market_phase": state.market_phase,
|
||||||
|
"execution_quality": state.execution_quality,
|
||||||
|
"execution_quality_reason": state.execution_quality_reason,
|
||||||
|
"spread_percent": state.spread_percent,
|
||||||
|
}
|
||||||
|
|
||||||
|
def _market_confidence_score(self, state: AutoTradeState) -> float:
|
||||||
|
market_state = state.market_state
|
||||||
|
strength = state.market_trend_strength
|
||||||
|
quality = state.market_trend_quality
|
||||||
|
phase = state.market_phase
|
||||||
|
|
||||||
|
if market_state in {"HIGH_VOLATILITY", "LOW_VOLATILITY", "RANGE", "UNKNOWN", None}:
|
||||||
|
return 0.25
|
||||||
|
|
||||||
|
score = 0.65
|
||||||
|
|
||||||
|
if strength == "STRONG":
|
||||||
|
score += 0.2
|
||||||
|
elif strength == "NORMAL":
|
||||||
|
score += 0.1
|
||||||
|
elif strength == "WEAK":
|
||||||
|
score -= 0.25
|
||||||
|
|
||||||
|
if quality == "CLEAN":
|
||||||
|
score += 0.1
|
||||||
|
elif quality == "NOISY":
|
||||||
|
score -= 0.25
|
||||||
|
|
||||||
|
if phase == "IMPULSE":
|
||||||
|
score += 0.1
|
||||||
|
elif phase == "PULLBACK":
|
||||||
|
score -= 0.25
|
||||||
|
elif phase in {"RANGE", "SQUEEZE"}:
|
||||||
|
score -= 0.3
|
||||||
|
|
||||||
|
return self._clamp_score(score)
|
||||||
|
|
||||||
|
def _execution_quality_confidence_score(self, state: AutoTradeState) -> float:
|
||||||
|
quality = state.execution_quality
|
||||||
|
reason = state.execution_quality_reason
|
||||||
|
|
||||||
|
if quality == "GOOD":
|
||||||
|
return 1.0
|
||||||
|
|
||||||
|
if quality == "WARNING":
|
||||||
|
if reason == "WIDE_SPREAD":
|
||||||
|
return 0.65
|
||||||
|
|
||||||
|
if reason == "AGING_SNAPSHOT":
|
||||||
|
return 0.6
|
||||||
|
|
||||||
|
if reason == "SNAPSHOT_UNAVAILABLE":
|
||||||
|
return 0.55
|
||||||
|
|
||||||
|
return 0.6
|
||||||
|
|
||||||
|
if quality == "BLOCKED":
|
||||||
|
return 0.0
|
||||||
|
|
||||||
|
return 0.5
|
||||||
|
|
||||||
|
def _execution_confidence_level(self, score: float) -> str:
|
||||||
|
if score >= 0.75:
|
||||||
|
return "HIGH"
|
||||||
|
|
||||||
|
if score >= self._execution_confidence_required_score:
|
||||||
|
return "NORMAL"
|
||||||
|
|
||||||
|
return "LOW"
|
||||||
|
|
||||||
|
def _execution_confidence_reason(self, state: AutoTradeState) -> str:
|
||||||
|
score = state.execution_confidence_score
|
||||||
|
|
||||||
|
if score is None:
|
||||||
|
return "execution confidence не рассчитан"
|
||||||
|
|
||||||
|
if score < self._execution_confidence_required_score:
|
||||||
|
return "низкая совокупная уверенность входа"
|
||||||
|
|
||||||
|
if state.execution_confidence_level == "HIGH":
|
||||||
|
return "высокая совокупная уверенность входа"
|
||||||
|
|
||||||
|
return "достаточная совокупная уверенность входа"
|
||||||
|
|
||||||
|
def _clamp_score(self, value: float | int | None) -> float:
|
||||||
|
if value is None:
|
||||||
|
return 0.0
|
||||||
|
|
||||||
|
return max(0.0, min(1.0, float(value)))
|
||||||
|
|
||||||
def _sync_execution_semantic_state(self, state: AutoTradeState) -> None:
|
def _sync_execution_semantic_state(self, state: AutoTradeState) -> None:
|
||||||
if state.execution_quality == "BLOCKED":
|
if state.execution_quality == "BLOCKED":
|
||||||
state.execution_semantic_status = "BLOCKED"
|
state.execution_semantic_status = "BLOCKED"
|
||||||
@@ -1278,6 +1437,21 @@ class AutoTradeService:
|
|||||||
state.execution_semantic_reason = state.execution_quality_reason
|
state.execution_semantic_reason = state.execution_quality_reason
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if state.decision_status == "BLOCKED":
|
||||||
|
state.execution_semantic_status = "BLOCKED"
|
||||||
|
|
||||||
|
if (
|
||||||
|
state.execution_confidence_score is not None
|
||||||
|
and state.execution_confidence_score < self._execution_confidence_required_score
|
||||||
|
):
|
||||||
|
state.execution_semantic_message = "⛔ Исполнение · низкая уверенность"
|
||||||
|
state.execution_semantic_reason = state.execution_confidence_reason
|
||||||
|
return
|
||||||
|
|
||||||
|
state.execution_semantic_message = "⛔ Исполнение · сигнал заблокирован"
|
||||||
|
state.execution_semantic_reason = state.decision_reason
|
||||||
|
return
|
||||||
|
|
||||||
if state.position_side != "NONE":
|
if state.position_side != "NONE":
|
||||||
state.execution_semantic_status = "POSITION_OPEN"
|
state.execution_semantic_status = "POSITION_OPEN"
|
||||||
state.execution_semantic_message = "📌 Исполнение · позиция открыта"
|
state.execution_semantic_message = "📌 Исполнение · позиция открыта"
|
||||||
|
|||||||
@@ -192,4 +192,19 @@ class AutoTradeState:
|
|||||||
execution_semantic_message: str | None = None
|
execution_semantic_message: str | None = None
|
||||||
|
|
||||||
# техническая детализация для логов / отладки
|
# техническая детализация для логов / отладки
|
||||||
execution_semantic_reason: str | None = None
|
execution_semantic_reason: str | None = None
|
||||||
|
|
||||||
|
# итоговая execution confidence от 0.0 до 1.0
|
||||||
|
execution_confidence_score: float | None = None
|
||||||
|
|
||||||
|
# уровень confidence: LOW / NORMAL / HIGH
|
||||||
|
execution_confidence_level: str | None = None
|
||||||
|
|
||||||
|
# минимальный score для допуска execution
|
||||||
|
execution_confidence_required_score: float | None = None
|
||||||
|
|
||||||
|
# человекочитаемая причина confidence-оценки
|
||||||
|
execution_confidence_reason: str | None = None
|
||||||
|
|
||||||
|
# детализация факторов confidence для логов / отладки
|
||||||
|
execution_confidence_factors: dict | None = None
|
||||||
@@ -893,6 +893,79 @@
|
|||||||
- execution runtime подготовлен к semantic trade lifecycle
|
- execution runtime подготовлен к semantic trade lifecycle
|
||||||
- execution runtime подготовлен к professional execution diagnostics
|
- execution runtime подготовлен к professional execution diagnostics
|
||||||
|
|
||||||
|
#### 07.4.4.1.9.5 ✅ Execution Confidence Engine
|
||||||
|
- реализован execution confidence runtime
|
||||||
|
- реализован probabilistic execution engine
|
||||||
|
- реализован execution confidence orchestrator
|
||||||
|
- реализован composite execution scoring
|
||||||
|
- execution runtime переведён на probabilistic scoring model
|
||||||
|
- execution runtime перестал зависеть только от signal confidence
|
||||||
|
- execution runtime теперь оценивает совокупное качество execution context
|
||||||
|
- execution runtime теперь анализирует вероятность качественного входа
|
||||||
|
- execution runtime теперь анализирует continuation quality
|
||||||
|
- execution runtime теперь анализирует market quality
|
||||||
|
- execution runtime теперь анализирует execution quality
|
||||||
|
- execution runtime теперь анализирует market structure quality
|
||||||
|
- execution runtime теперь анализирует directional continuation
|
||||||
|
- execution runtime теперь анализирует trend persistence
|
||||||
|
- execution runtime теперь анализирует market phase quality
|
||||||
|
- execution runtime теперь анализирует liquidity quality
|
||||||
|
- execution runtime теперь анализирует runtime degradation
|
||||||
|
- execution runtime теперь анализирует snapshot quality
|
||||||
|
- execution runtime теперь анализирует spread impact
|
||||||
|
- execution runtime теперь анализирует confirmation quality
|
||||||
|
- реализован weighted execution scoring
|
||||||
|
- signal confidence интегрирован в execution scoring
|
||||||
|
- signal confirmation интегрирован в execution scoring
|
||||||
|
- market semantic layer интегрирован в execution scoring
|
||||||
|
- execution quality layer интегрирован в execution scoring
|
||||||
|
- spread интегрирован в probabilistic execution scoring
|
||||||
|
- stale snapshots интегрированы в probabilistic execution scoring
|
||||||
|
- noisy market интегрирован в probabilistic execution scoring
|
||||||
|
- pullback market интегрирован в probabilistic execution scoring
|
||||||
|
- range market интегрирован в probabilistic execution scoring
|
||||||
|
- squeeze market интегрирован в probabilistic execution scoring
|
||||||
|
- continuation strength интегрирован в execution scoring
|
||||||
|
- trend quality интегрирован в execution scoring
|
||||||
|
- directional impulse интегрирован в execution scoring
|
||||||
|
- реализован execution confidence threshold
|
||||||
|
- реализован adaptive execution gating
|
||||||
|
- реализован probabilistic execution blocking
|
||||||
|
- execution runtime теперь умеет low-confidence blocking
|
||||||
|
- execution runtime теперь умеет explainable confidence diagnostics
|
||||||
|
- execution runtime теперь умеет explainable confidence scoring
|
||||||
|
- execution runtime теперь умеет explainable execution probability
|
||||||
|
- execution runtime теперь умеет explainable execution weakness
|
||||||
|
- execution runtime теперь умеет explainable unsafe execution context
|
||||||
|
- реализованы execution confidence levels:
|
||||||
|
- HIGH
|
||||||
|
- NORMAL
|
||||||
|
- LOW
|
||||||
|
- реализованы execution confidence diagnostics:
|
||||||
|
- 🧠 Уверенность входа · высокая
|
||||||
|
- 🧠 Уверенность входа · нормальная
|
||||||
|
- 🧠 Уверенность входа · низкая
|
||||||
|
- реализовано semantic execution состояние:
|
||||||
|
- ⛔ Исполнение · низкая уверенность
|
||||||
|
- execution runtime стал менее deterministic
|
||||||
|
- execution runtime стал менее reactive
|
||||||
|
- execution runtime стал explainable
|
||||||
|
- execution runtime стал probabilistic
|
||||||
|
- execution runtime стал ближе к professional execution engine
|
||||||
|
- execution runtime стал лучше фильтровать noise execution
|
||||||
|
- execution runtime стал лучше фильтровать weak continuation
|
||||||
|
- execution runtime стал безопаснее
|
||||||
|
- execution runtime стал стабильнее
|
||||||
|
- execution runtime стал ближе к institutional execution logic
|
||||||
|
- execution runtime подготовлен к adaptive position sizing
|
||||||
|
- execution runtime подготовлен к probabilistic trade selection
|
||||||
|
- execution runtime подготовлен к smart execution routing
|
||||||
|
- execution runtime подготовлен к multi-factor trade ranking
|
||||||
|
- execution runtime подготовлен к execution quality ranking
|
||||||
|
- execution runtime подготовлен к adaptive execution thresholds
|
||||||
|
- execution runtime подготовлен к portfolio-level execution scoring
|
||||||
|
- execution runtime подготовлен к execution AI layer
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### 07.4.5
|
### 07.4.5
|
||||||
|
|||||||
@@ -869,6 +869,79 @@
|
|||||||
- execution runtime подготовлен к semantic trade lifecycle
|
- execution runtime подготовлен к semantic trade lifecycle
|
||||||
- execution runtime подготовлен к professional execution diagnostics
|
- execution runtime подготовлен к professional execution diagnostics
|
||||||
|
|
||||||
|
#### 07.4.4.1.9.5 ✅ Execution Confidence Engine
|
||||||
|
- реализован execution confidence runtime
|
||||||
|
- реализован probabilistic execution engine
|
||||||
|
- реализован execution confidence orchestrator
|
||||||
|
- реализован composite execution scoring
|
||||||
|
- execution runtime переведён на probabilistic scoring model
|
||||||
|
- execution runtime перестал зависеть только от signal confidence
|
||||||
|
- execution runtime теперь оценивает совокупное качество execution context
|
||||||
|
- execution runtime теперь анализирует вероятность качественного входа
|
||||||
|
- execution runtime теперь анализирует continuation quality
|
||||||
|
- execution runtime теперь анализирует market quality
|
||||||
|
- execution runtime теперь анализирует execution quality
|
||||||
|
- execution runtime теперь анализирует market structure quality
|
||||||
|
- execution runtime теперь анализирует directional continuation
|
||||||
|
- execution runtime теперь анализирует trend persistence
|
||||||
|
- execution runtime теперь анализирует market phase quality
|
||||||
|
- execution runtime теперь анализирует liquidity quality
|
||||||
|
- execution runtime теперь анализирует runtime degradation
|
||||||
|
- execution runtime теперь анализирует snapshot quality
|
||||||
|
- execution runtime теперь анализирует spread impact
|
||||||
|
- execution runtime теперь анализирует confirmation quality
|
||||||
|
- реализован weighted execution scoring
|
||||||
|
- signal confidence интегрирован в execution scoring
|
||||||
|
- signal confirmation интегрирован в execution scoring
|
||||||
|
- market semantic layer интегрирован в execution scoring
|
||||||
|
- execution quality layer интегрирован в execution scoring
|
||||||
|
- spread интегрирован в probabilistic execution scoring
|
||||||
|
- stale snapshots интегрированы в probabilistic execution scoring
|
||||||
|
- noisy market интегрирован в probabilistic execution scoring
|
||||||
|
- pullback market интегрирован в probabilistic execution scoring
|
||||||
|
- range market интегрирован в probabilistic execution scoring
|
||||||
|
- squeeze market интегрирован в probabilistic execution scoring
|
||||||
|
- continuation strength интегрирован в execution scoring
|
||||||
|
- trend quality интегрирован в execution scoring
|
||||||
|
- directional impulse интегрирован в execution scoring
|
||||||
|
- реализован execution confidence threshold
|
||||||
|
- реализован adaptive execution gating
|
||||||
|
- реализован probabilistic execution blocking
|
||||||
|
- execution runtime теперь умеет low-confidence blocking
|
||||||
|
- execution runtime теперь умеет explainable confidence diagnostics
|
||||||
|
- execution runtime теперь умеет explainable confidence scoring
|
||||||
|
- execution runtime теперь умеет explainable execution probability
|
||||||
|
- execution runtime теперь умеет explainable execution weakness
|
||||||
|
- execution runtime теперь умеет explainable unsafe execution context
|
||||||
|
- реализованы execution confidence levels:
|
||||||
|
- HIGH
|
||||||
|
- NORMAL
|
||||||
|
- LOW
|
||||||
|
- реализованы execution confidence diagnostics:
|
||||||
|
- 🧠 Уверенность входа · высокая
|
||||||
|
- 🧠 Уверенность входа · нормальная
|
||||||
|
- 🧠 Уверенность входа · низкая
|
||||||
|
- реализовано semantic execution состояние:
|
||||||
|
- ⛔ Исполнение · низкая уверенность
|
||||||
|
- execution runtime стал менее deterministic
|
||||||
|
- execution runtime стал менее reactive
|
||||||
|
- execution runtime стал explainable
|
||||||
|
- execution runtime стал probabilistic
|
||||||
|
- execution runtime стал ближе к professional execution engine
|
||||||
|
- execution runtime стал лучше фильтровать noise execution
|
||||||
|
- execution runtime стал лучше фильтровать weak continuation
|
||||||
|
- execution runtime стал безопаснее
|
||||||
|
- execution runtime стал стабильнее
|
||||||
|
- execution runtime стал ближе к institutional execution logic
|
||||||
|
- execution runtime подготовлен к adaptive position sizing
|
||||||
|
- execution runtime подготовлен к probabilistic trade selection
|
||||||
|
- execution runtime подготовлен к smart execution routing
|
||||||
|
- execution runtime подготовлен к multi-factor trade ranking
|
||||||
|
- execution runtime подготовлен к execution quality ranking
|
||||||
|
- execution runtime подготовлен к adaptive execution thresholds
|
||||||
|
- execution runtime подготовлен к portfolio-level execution scoring
|
||||||
|
- execution runtime подготовлен к execution AI layer
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### 07.4.5
|
### 07.4.5
|
||||||
|
|||||||
329
docs/stages/stage-07_4_4_1_9_5-execution_confidence_engine.md
Normal file
329
docs/stages/stage-07_4_4_1_9_5-execution_confidence_engine.md
Normal file
@@ -0,0 +1,329 @@
|
|||||||
|
# 07.4.4.1.9.5 Execution Confidence Engine
|
||||||
|
|
||||||
|
## Что сделано
|
||||||
|
|
||||||
|
Выполнено внедрение полноценного Execution Confidence Engine для AutoTrade runtime.
|
||||||
|
|
||||||
|
Основная задача этапа — перевести execution runtime от бинарной модели:
|
||||||
|
|
||||||
|
```text
|
||||||
|
READY / NOT READY
|
||||||
|
```
|
||||||
|
|
||||||
|
к вероятностной execution-модели:
|
||||||
|
|
||||||
|
```text
|
||||||
|
execution confidence scoring
|
||||||
|
```
|
||||||
|
|
||||||
|
Execution runtime теперь оценивает не только сам факт наличия сигнала, но и совокупное качество текущего execution context.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Что изменилось в аналитике
|
||||||
|
|
||||||
|
### Добавлен probabilistic execution runtime
|
||||||
|
|
||||||
|
Execution layer перестал принимать решение только по одному сигналу стратегии.
|
||||||
|
|
||||||
|
Теперь execution runtime вычисляет:
|
||||||
|
|
||||||
|
```text
|
||||||
|
execution_confidence_score
|
||||||
|
```
|
||||||
|
|
||||||
|
который отражает:
|
||||||
|
|
||||||
|
- вероятность качественного входа
|
||||||
|
- качество текущего execution context
|
||||||
|
- устойчивость market structure
|
||||||
|
- вероятность continuation
|
||||||
|
- качество liquidity/runtime
|
||||||
|
- степень подтверждения сигнала
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлен Execution Confidence Engine
|
||||||
|
|
||||||
|
В state добавлены:
|
||||||
|
|
||||||
|
- execution_confidence_score
|
||||||
|
- execution_confidence_level
|
||||||
|
- execution_confidence_required_score
|
||||||
|
- execution_confidence_reason
|
||||||
|
- execution_confidence_factors
|
||||||
|
|
||||||
|
Execution runtime получил отдельный confidence orchestration layer.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлен confidence scoring orchestrator
|
||||||
|
|
||||||
|
Реализован:
|
||||||
|
|
||||||
|
```python
|
||||||
|
_sync_execution_confidence_state()
|
||||||
|
```
|
||||||
|
|
||||||
|
Он агрегирует:
|
||||||
|
|
||||||
|
- signal confidence
|
||||||
|
- signal confirmation progress
|
||||||
|
- market structure quality
|
||||||
|
- execution quality
|
||||||
|
- spread diagnostics
|
||||||
|
- snapshot quality
|
||||||
|
- market phase
|
||||||
|
- trend strength
|
||||||
|
- trend quality
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Execution runtime стал multi-factor
|
||||||
|
|
||||||
|
Теперь execution confidence считается как weighted composite score.
|
||||||
|
|
||||||
|
Execution runtime больше не использует только:
|
||||||
|
|
||||||
|
```text
|
||||||
|
signal confidence
|
||||||
|
```
|
||||||
|
|
||||||
|
Execution runtime теперь учитывает одновременно:
|
||||||
|
|
||||||
|
| Компонент | Вес |
|
||||||
|
|---|---|
|
||||||
|
| signal confidence | 35% |
|
||||||
|
| signal confirmation | 20% |
|
||||||
|
| market quality | 25% |
|
||||||
|
| execution quality | 20% |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлена market confidence аналитика
|
||||||
|
|
||||||
|
Реализован:
|
||||||
|
|
||||||
|
```python
|
||||||
|
_market_confidence_score()
|
||||||
|
```
|
||||||
|
|
||||||
|
Теперь execution runtime анализирует:
|
||||||
|
|
||||||
|
- market trend
|
||||||
|
- market strength
|
||||||
|
- market quality
|
||||||
|
- market phase
|
||||||
|
- continuation quality
|
||||||
|
- impulse persistence
|
||||||
|
- pullback probability
|
||||||
|
- range probability
|
||||||
|
- squeeze probability
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Execution runtime теперь differentiates market quality
|
||||||
|
|
||||||
|
Execution engine начал различать:
|
||||||
|
|
||||||
|
```text
|
||||||
|
STRONG IMPULSE
|
||||||
|
```
|
||||||
|
|
||||||
|
и:
|
||||||
|
|
||||||
|
```text
|
||||||
|
WEAK / NOISY / RANGE MARKET
|
||||||
|
```
|
||||||
|
|
||||||
|
Даже если стратегия даёт BUY/SELL.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлена continuation-aware аналитика
|
||||||
|
|
||||||
|
Execution runtime теперь повышает confidence при:
|
||||||
|
|
||||||
|
- IMPULSE
|
||||||
|
- STRONG TREND
|
||||||
|
- CLEAN TREND
|
||||||
|
- directional continuation
|
||||||
|
|
||||||
|
и понижает confidence при:
|
||||||
|
|
||||||
|
- PULLBACK
|
||||||
|
- RANGE
|
||||||
|
- SQUEEZE
|
||||||
|
- WEAK TREND
|
||||||
|
- NOISY TREND
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлена execution quality аналитика
|
||||||
|
|
||||||
|
Реализован:
|
||||||
|
|
||||||
|
```python
|
||||||
|
_execution_quality_confidence_score()
|
||||||
|
```
|
||||||
|
|
||||||
|
Execution runtime теперь probabilistically учитывает:
|
||||||
|
|
||||||
|
- spread quality
|
||||||
|
- stale snapshots
|
||||||
|
- runtime degradation
|
||||||
|
- market freshness
|
||||||
|
- liquidity degradation
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Spread стал частью confidence scoring
|
||||||
|
|
||||||
|
Spread теперь влияет не только на BLOCKED state.
|
||||||
|
|
||||||
|
Spread теперь влияет на:
|
||||||
|
|
||||||
|
```text
|
||||||
|
execution confidence probability
|
||||||
|
```
|
||||||
|
|
||||||
|
Даже если execution формально ещё разрешён.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлена confidence-level аналитика
|
||||||
|
|
||||||
|
Execution runtime теперь классифицирует:
|
||||||
|
|
||||||
|
- HIGH
|
||||||
|
- NORMAL
|
||||||
|
- LOW
|
||||||
|
|
||||||
|
Execution confidence стал explainable.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлена explainable confidence аналитика
|
||||||
|
|
||||||
|
Теперь runtime умеет semantic-объяснять:
|
||||||
|
|
||||||
|
- высокая совокупная уверенность входа
|
||||||
|
- достаточная совокупная уверенность входа
|
||||||
|
- низкая совокупная уверенность входа
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлен adaptive execution threshold
|
||||||
|
|
||||||
|
Execution runtime получил:
|
||||||
|
|
||||||
|
```python
|
||||||
|
_execution_confidence_required_score
|
||||||
|
```
|
||||||
|
|
||||||
|
Execution больше не допускается при слабом composite context.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлена probabilistic execution blocking логика
|
||||||
|
|
||||||
|
Теперь execution может быть заблокирован даже если:
|
||||||
|
|
||||||
|
- сигнал подтверждён
|
||||||
|
- signal READY
|
||||||
|
- execution formally available
|
||||||
|
|
||||||
|
если:
|
||||||
|
|
||||||
|
```text
|
||||||
|
execution_confidence_score < threshold
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Добавлен confidence-aware semantic execution runtime
|
||||||
|
|
||||||
|
Execution Semantic Layer теперь синхронизирован с Confidence Engine.
|
||||||
|
|
||||||
|
Добавлено semantic состояние:
|
||||||
|
|
||||||
|
```text
|
||||||
|
⛔ Исполнение · низкая уверенность
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Что изменилось в Telegram UI
|
||||||
|
|
||||||
|
Теперь UI показывает:
|
||||||
|
|
||||||
|
```text
|
||||||
|
🧠 Уверенность входа · 78% высокая
|
||||||
|
🧠 Уверенность входа · 61% нормальная
|
||||||
|
🧠 Уверенность входа · 42% низкая
|
||||||
|
```
|
||||||
|
|
||||||
|
Execution runtime стал визуально explainable.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Что изменилось в execution безопасности
|
||||||
|
|
||||||
|
Теперь execution layer умеет:
|
||||||
|
|
||||||
|
- блокировать слабые continuation setups
|
||||||
|
- блокировать noisy market entries
|
||||||
|
- блокировать weak trend execution
|
||||||
|
- блокировать low-confidence execution
|
||||||
|
- предотвращать execution в probabilistically unsafe conditions
|
||||||
|
- снижать вероятность ложных входов
|
||||||
|
- снижать вероятность noise execution
|
||||||
|
- снижать вероятность unstable continuation execution
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Что изменилось в архитектуре
|
||||||
|
|
||||||
|
Execution runtime теперь разделён на:
|
||||||
|
|
||||||
|
```text
|
||||||
|
signal layer
|
||||||
|
confirmation layer
|
||||||
|
market semantic layer
|
||||||
|
execution quality layer
|
||||||
|
execution confidence layer
|
||||||
|
execution semantic layer
|
||||||
|
```
|
||||||
|
|
||||||
|
Execution architecture стала modular.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Проверка
|
||||||
|
|
||||||
|
После внедрения:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python -m compileall src
|
||||||
|
```
|
||||||
|
|
||||||
|
Runtime-проверка:
|
||||||
|
|
||||||
|
- execution confidence корректно рассчитывается
|
||||||
|
- confidence корректно влияет на execution
|
||||||
|
- low confidence корректно блокирует вход
|
||||||
|
- HIGH/NORMAL/LOW корректно отображаются
|
||||||
|
- Telegram UI показывает execution confidence
|
||||||
|
- spread влияет на confidence scoring
|
||||||
|
- weak market снижает confidence
|
||||||
|
- strong continuation повышает confidence
|
||||||
|
- noisy market снижает confidence
|
||||||
|
- execution semantic layer синхронизирован с confidence runtime
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Результат
|
||||||
|
|
||||||
|
Этап завершил переход от deterministic execution runtime к probabilistic execution runtime.
|
||||||
|
|
||||||
|
Execution engine теперь оценивает не только наличие сигнала, но и вероятность качественного исполнения сделки.
|
||||||
Reference in New Issue
Block a user