feat: unify market/portfolio/system UI, improve exchange errors and asset valuation

This commit is contained in:
2026-04-22 18:21:34 +03:00
parent 2a9ef16524
commit 1fb72ced58
13 changed files with 2034 additions and 822 deletions

View File

@@ -1,3 +1,5 @@
# app/src/integrations/exchange/exceptions.py
from __future__ import annotations
@@ -11,3 +13,41 @@ class ExchangeConnectionError(ExchangeError):
class ExchangeResponseError(ExchangeError):
"""Unexpected HTTP response or malformed JSON."""
def is_exchange_time_sync_error(exc: Exception) -> bool:
text = str(exc).lower()
return (
"-1021" in text
or "doesn't match server time" in text
or "server time" in text and "match" in text
or "рассинхрон" in text
)
def format_exchange_error_for_user(exc: Exception) -> str:
if is_exchange_time_sync_error(exc):
return (
"Биржа отклонила запрос из-за рассинхронизации времени. "
"Проверь системное время и повтори попытку."
)
if isinstance(exc, ExchangeConnectionError):
return (
"Не удалось получить данные биржи: таймаут или ошибка сети. "
"Попробуй ещё раз через несколько секунд."
)
if isinstance(exc, ExchangeResponseError):
return (
"Биржа вернула ошибку ответа. "
"Попробуй ещё раз через несколько секунд."
)
if isinstance(exc, ExchangeError):
return (
"Не удалось получить данные биржи. "
"Попробуй ещё раз через несколько секунд."
)
return "Временная ошибка получения данных биржи. Попробуй ещё раз через несколько секунд."

View File

@@ -1,3 +1,5 @@
# app/src/integrations/exchange/symbol_utils.py
from __future__ import annotations