Stage 07.4.4.1.14 — Execution refactoring and runtime semantics

This commit is contained in:
2026-07-02 16:25:18 +03:00
parent d9e6392e28
commit e08c604ff5
72 changed files with 13626 additions and 4233 deletions

View File

@@ -235,11 +235,29 @@ class AutoExecutionQualityMixin:
# синхронизировать runtime quality исполнения
def _sync_execution_quality_state(self, state: AutoTradeState) -> None:
if state.market_is_open is False:
return
try:
snapshot = ExchangeService().get_market_snapshot(
state.symbol,
runtime_key="auto",
)
age_seconds = safe_float(snapshot.get("age_seconds"))
if (
age_seconds is not None
and age_seconds > self._warning_snapshot_age_seconds
):
try:
snapshot = ExchangeService().refresh_market_snapshot_cache(
state.symbol,
runtime_key="auto",
)
except Exception:
pass
except Exception as exc:
fallback_price = None
@@ -253,13 +271,22 @@ class AutoExecutionQualityMixin:
except Exception:
pass
# Snapshot недоступен — очищаем все pricing-поля,
# чтобы UI/execution не использовали старые bid/ask/last.
state.snapshot_age_seconds = None
state.spread_percent = None
state.execution_price_source = None
state.execution_price_age_seconds = None
state.execution_bid_price = None
state.execution_ask_price = None
state.execution_last_price = fallback_price
state.execution_price_freshness = "UNKNOWN"
if fallback_price is not None and fallback_price > 0:
state.execution_quality = "WARNING"
state.execution_quality_reason = "SNAPSHOT_UNAVAILABLE"
state.execution_quality_message = "нет depth snapshot"
state.execution_block_reason = None
state.market_runtime_degraded = True
else:
status = build_exchange_error_status(exc)