Stage 05.5 - trade UI unification and mode display

This commit is contained in:
2026-04-18 20:45:26 +03:00
parent e9fd3ea4a0
commit 2be2ac1d30
4 changed files with 925 additions and 198 deletions

View File

@@ -15,30 +15,90 @@ from src.telegram.handlers.trade.new_order import (
router = Router(name="trade_main")
def _mode_line() -> str:
from src.core.system_status import get_runtime_mode_label
return f"Режим: <b>{get_runtime_mode_label()}</b>\n\n"
def _trade_screen(title: str) -> str:
return (
f"<b>📊 Торговля — {title}</b>\n"
f"{_mode_line()}"
"Выбери раздел"
)
# =========================
# KEYBOARDS
# =========================
def _trade_home_keyboard() -> InlineKeyboardMarkup:
builder = InlineKeyboardBuilder()
builder.button(text="📝 Новый ордер", callback_data="trade:new_order")
builder.button(text="📂 Черновики", callback_data="trade:drafts")
builder.button(text="⚙️ Настройки ордера", callback_data="trade:settings")
builder.button(text=" Справка", callback_data="trade:help")
builder.button(text="📝 Ордер", callback_data="trade:new_order")
builder.button(text="📂 Ордера", callback_data="trade:orders")
builder.button(text="📜 История", callback_data="trade:history")
builder.button(text=" Настройки", callback_data="trade:settings")
builder.adjust(2, 2)
return builder.as_markup()
def _trade_back_keyboard() -> InlineKeyboardMarkup:
def _trade_home_button() -> InlineKeyboardMarkup:
builder = InlineKeyboardBuilder()
builder.button(text="⬅️ К торговле", callback_data="trade:home")
builder.button(text="🏠 К торговле", callback_data="trade:home")
return builder.as_markup()
def _orders_menu_keyboard() -> InlineKeyboardMarkup:
builder = InlineKeyboardBuilder()
builder.button(text="📂 Черновики", callback_data="trade:orders:drafts")
builder.button(text="🏠 К торговле", callback_data="trade:home")
builder.adjust(2)
return builder.as_markup()
def _history_menu_keyboard() -> InlineKeyboardMarkup:
builder = InlineKeyboardBuilder()
builder.button(text="✅ Исполненные", callback_data="trade:history:filled")
builder.button(text="🚫 Отменённые", callback_data="trade:history:canceled")
builder.button(text="🏠 К торговле", callback_data="trade:home")
builder.adjust(2, 1)
return builder.as_markup()
def _settings_menu_keyboard() -> InlineKeyboardMarkup:
builder = InlineKeyboardBuilder()
builder.button(text="⚙️ Параметры", callback_data="trade:settings:params")
builder.button(text="🔁 Режим", callback_data="trade:settings:mode")
builder.button(text=" Справка", callback_data="trade:settings:help")
builder.button(text="🏠 К торговле", callback_data="trade:home")
builder.adjust(2, 2)
return builder.as_markup()
# =========================
# TEXTS
# =========================
def _trade_home_text() -> str:
return (
"<b>⚡ Торговля</b>\n\n"
"<b>‼️ Режим черновика</b>"
)
return _trade_screen("Основной экран")
def _trade_orders_text() -> str:
return _trade_screen("Ордера")
@router.message(F.text == "⚡ Торговля")
def _trade_history_text() -> str:
return _trade_screen("История")
def _trade_settings_text() -> str:
return _trade_screen("Настройки")
# =========================
# ENTRY
# =========================
@router.message(F.text.in_({"📊 Торговля", "⚡ Торговля", "Торговля"}))
async def open_trade(message: Message) -> None:
await message.answer(
_trade_home_text(),
@@ -47,8 +107,13 @@ async def open_trade(message: Message) -> None:
@router.callback_query(F.data == "trade:home")
async def open_trade_home_callback(callback: CallbackQuery) -> None:
async def open_trade_home_callback(
callback: CallbackQuery,
state: FSMContext,
) -> None:
await state.clear()
await callback.answer()
if callback.message is not None:
await callback.message.edit_text(
_trade_home_text(),
@@ -56,6 +121,10 @@ async def open_trade_home_callback(callback: CallbackQuery) -> None:
)
# =========================
# NEW ORDER
# =========================
@router.callback_query(F.data == "trade:new_order")
async def open_new_order_from_trade(
callback: CallbackQuery,
@@ -66,39 +135,110 @@ async def open_new_order_from_trade(
await start_new_order_draft(callback.message, state, edit_mode=True)
@router.callback_query(F.data == "trade:drafts")
async def open_drafts_from_trade(callback: CallbackQuery) -> None:
# =========================
# ORDERS
# =========================
@router.callback_query(F.data == "trade:orders")
async def open_orders_from_trade(callback: CallbackQuery) -> None:
await callback.answer()
if callback.message is not None:
await callback.message.edit_text(
_trade_orders_text(),
reply_markup=_orders_menu_keyboard(),
)
@router.callback_query(F.data == "trade:orders:drafts")
async def open_drafts_from_orders(callback: CallbackQuery) -> None:
await callback.answer()
if callback.message is not None:
await show_recent_drafts(callback.message, edit_mode=True, page=1)
# =========================
# HISTORY
# =========================
@router.callback_query(F.data == "trade:history")
async def open_trade_history(callback: CallbackQuery) -> None:
await callback.answer()
if callback.message is not None:
await callback.message.edit_text(
_trade_history_text(),
reply_markup=_history_menu_keyboard(),
)
@router.callback_query(F.data == "trade:history:filled")
async def open_filled_history(callback: CallbackQuery) -> None:
await callback.answer()
if callback.message is not None:
await callback.message.edit_text(
"<b>📊 Торговля — История</b>\n\n"
"Шаг 1/1: Исполненные\n"
"Раздел в разработке.",
reply_markup=_trade_home_button(),
)
@router.callback_query(F.data == "trade:history:canceled")
async def open_canceled_history(callback: CallbackQuery) -> None:
await callback.answer()
if callback.message is not None:
await callback.message.edit_text(
"<b>📊 Торговля — История</b>\n\n"
"Шаг 1/1: Отменённые\n"
"Раздел в разработке.",
reply_markup=_trade_home_button(),
)
# =========================
# SETTINGS
# =========================
@router.callback_query(F.data == "trade:settings")
async def open_trade_settings(callback: CallbackQuery) -> None:
await callback.answer()
if callback.message is not None:
await callback.message.edit_text(
"<b>⚡ Торговля — Настройки ордера</b>\n\n"
"Раздел в разработке.\n\n"
"Планируется добавить:\n"
"• параметры ордера по умолчанию\n"
"• пресеты количества\n"
"• режим цены: Bid / Ask / Last",
reply_markup=_trade_back_keyboard(),
_trade_settings_text(),
reply_markup=_settings_menu_keyboard(),
)
@router.callback_query(F.data == "trade:help")
async def open_trade_help(callback: CallbackQuery) -> None:
@router.callback_query(F.data == "trade:settings:params")
async def open_trade_settings_params(callback: CallbackQuery) -> None:
await callback.answer()
if callback.message is not None:
await callback.message.edit_text(
"<b> Торговля — Справка</b>\n\n"
"<b>Режим черновика</b> — ордер не отправляется на биржу.\n\n"
"Сейчас можно:\n"
"• собрать черновик ордера\n"
"• проверить параметры\n"
"• сохранить черновик в базу\n\n"
"Реальная отправка ордера появится позже.",
reply_markup=_trade_back_keyboard(),
"<b>📊 Торговля — Настройки</b>\n\n"
"Шаг 1/1: Параметры ордера\n"
"Раздел в разработке.",
reply_markup=_trade_home_button(),
)
@router.callback_query(F.data == "trade:settings:mode")
async def open_trade_settings_mode(callback: CallbackQuery) -> None:
await callback.answer()
if callback.message is not None:
await callback.message.edit_text(
"<b>📊 Торговля — Настройки</b>\n\n"
"Шаг 1/1: Режим работы\n"
"Текущий режим: <b>demo</b>",
reply_markup=_trade_home_button(),
)
@router.callback_query(F.data == "trade:settings:help")
async def open_trade_settings_help(callback: CallbackQuery) -> None:
await callback.answer()
if callback.message is not None:
await callback.message.edit_text(
"<b>📊 Торговля — Справка</b>\n\n"
"Шаг 1/1: Информация\n"
"Раздел в разработке.",
reply_markup=_trade_home_button(),
)

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ def build_main_menu_keyboard() -> ReplyKeyboardMarkup:
KeyboardButton(text="💼 Портфель"),
],
[
KeyboardButton(text=" Торговля"),
KeyboardButton(text="📊 Торговля"),
KeyboardButton(text="🤖 Авто"),
KeyboardButton(text="📒 Журнал"),
],

View File

@@ -27,6 +27,6 @@ SYSTEM_TEXT = (
MARKET_TEXT = "<b>📈 Рынок</b>\n\nРаздел пока в разработке."
PORTFOLIO_TEXT = "<b>💼 Портфель</b>\n\nРаздел пока в разработке."
TRADE_TEXT = "<b> Торговля</b>\n\nВыберите действие:\n<i>DRAFT режим</i>"
TRADE_TEXT = "<b>📊 Торговля</b>\n\nВыберите действие:\n<i>DRAFT режим</i>"
AUTO_TEXT = "<b>🤖 Авто</b>\n\nРаздел пока в разработке."
JOURNAL_TEXT = "<b>📒 Журнал</b>\n\nРаздел пока в разработке."