Stage 07.4.4.1.15 — Runtime Payload Builders & Auto Runtime Refactoring
This commit is contained in:
@@ -143,6 +143,29 @@ class AutoExecutionQualityMixin:
|
||||
|
||||
return "MARKET_BREAK"
|
||||
|
||||
# собрать payload изменения доступности биржи без изменения состояния
|
||||
def _build_exchange_availability_payload(
|
||||
self,
|
||||
*,
|
||||
state: AutoTradeState,
|
||||
status: ExchangeRuntimeStatus,
|
||||
reason: str,
|
||||
) -> dict[str, object]:
|
||||
return {
|
||||
"status": state.status,
|
||||
"symbol": state.symbol,
|
||||
"strategy": state.strategy,
|
||||
"exchange_status_code": status.code.value,
|
||||
"exchange_reason": status.reason,
|
||||
"execution_reason": reason,
|
||||
"is_open": status.is_open,
|
||||
"is_available": status.is_available,
|
||||
"is_auth_ok": status.is_auth_ok,
|
||||
"message": status.message,
|
||||
"raw_status": status.raw_status,
|
||||
"raw_error": status.raw_error,
|
||||
}
|
||||
|
||||
# залогировать изменение доступности биржи/рынка
|
||||
def _log_exchange_availability_if_changed(
|
||||
self,
|
||||
@@ -167,20 +190,11 @@ class AutoExecutionQualityMixin:
|
||||
message=status.ui_line,
|
||||
screen="auto",
|
||||
action="exchange_status",
|
||||
payload={
|
||||
"status": state.status,
|
||||
"symbol": state.symbol,
|
||||
"strategy": state.strategy,
|
||||
"exchange_status_code": status.code.value,
|
||||
"exchange_reason": status.reason,
|
||||
"execution_reason": reason,
|
||||
"is_open": status.is_open,
|
||||
"is_available": status.is_available,
|
||||
"is_auth_ok": status.is_auth_ok,
|
||||
"message": status.message,
|
||||
"raw_status": status.raw_status,
|
||||
"raw_error": status.raw_error,
|
||||
},
|
||||
payload=self._build_exchange_availability_payload(
|
||||
state=state,
|
||||
status=status,
|
||||
reason=reason,
|
||||
),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
@@ -437,6 +451,20 @@ class AutoExecutionQualityMixin:
|
||||
else:
|
||||
state.execution_price_freshness = "STALE"
|
||||
|
||||
# собрать payload изменения качества исполнения без изменения состояния
|
||||
def _build_execution_quality_payload(
|
||||
self,
|
||||
*,
|
||||
state: AutoTradeState,
|
||||
payload: dict[str, object],
|
||||
) -> dict[str, object]:
|
||||
return {
|
||||
**payload,
|
||||
"status": state.status,
|
||||
"symbol": state.symbol,
|
||||
"strategy": state.strategy,
|
||||
}
|
||||
|
||||
# записать событие изменения execution quality
|
||||
def _log_execution_quality_if_changed(
|
||||
self,
|
||||
@@ -462,12 +490,10 @@ class AutoExecutionQualityMixin:
|
||||
return
|
||||
|
||||
try:
|
||||
log_payload = {
|
||||
**payload,
|
||||
"status": state.status,
|
||||
"symbol": state.symbol,
|
||||
"strategy": state.strategy,
|
||||
}
|
||||
log_payload = self._build_execution_quality_payload(
|
||||
state=state,
|
||||
payload=payload,
|
||||
)
|
||||
|
||||
if quality == "BLOCKED":
|
||||
JournalService().log_ui_warning(
|
||||
|
||||
Reference in New Issue
Block a user