Page - Accounts

abstract

Register, view, and manage MT5 trading accounts — select the active account, view live balance/equity/margin, access trade history, and configure per-account settings.

Route

PropertyValue
Path/accounts
Filefrontend/src/app/accounts/page.tsx
Auth RequiredNo
LayoutRoot layout with sidebar
Dynamic SegmentNone

Sub-routes:

  • /accounts/[id]/history — Trade history for a specific account

Component Tree

AccountsPage (page.tsx)
├── AppHeader (title="Accounts")
├── Add Account Button → AddAccountDialog
│   └── Form: name, broker, login, password, server, is_live
├── Account List
│   └── AccountCard × N
│       ├── Account name + broker + live/demo badge
│       ├── Balance / Equity / Margin stats
│       ├── Margin Level gauge (colored: red/orange/yellow/green)
│       └── Actions: "Set Active" | "History" link | "Edit" | "Disconnect"
└── (empty state if no accounts registered)

Data Layer

Server State — Direct fetch

CallAPIEndpointTriggered When
Fetch all accountsaccountsApi.list()GET /api/v1/accountsOn mount
Create accountAddAccountDialog submitPOST /api/v1/accountsForm submission
Delete accountAccountCard disconnectDELETE /api/v1/accounts/{id}Disconnect button
Sync accountAccountCard syncPOST /api/v1/accounts/{id}/syncSync button

Global State — Zustand

StoreFields ReadActions Called
useTradingStoreaccounts, activeAccountIdsetAccounts, setActiveAccount, removeAccount

Local State — useState

VariableTypeInitialPurpose
(managed by Zustand)Account data lives in store

Page Lifecycle

Validation & Conditions

Render Conditions

ConditionWhat Shows
accounts.length === 0Empty state: "No accounts registered — add your first MT5 account"
account.id === activeAccountId"Active" badge on card; "Set Active" disabled
margin_level < 100Red margin gauge; warning icon
margin_level < 150Orange margin gauge
account.is_live"Live" badge (red); else "Demo" badge (gray)

Add Account Form Validation

FieldRulesError
loginPositive integer, required"Login must be a valid MT5 number"
passwordNon-empty, required"Password is required"
serverNon-empty, required"Server name is required"
name1–100 chars"Name is required"

(Validation is server-side — MT5 verifies credentials on POST /api/v1/accounts)