Account¶
Account information models and services.
Models¶
AccountInfo¶
AccountInfo
¶
Bases: BaseModel
Trading account details from MetaTrader 5.
Wraps the raw AccountInfo struct returned by mt5.account_info().
Contains both static account properties (leverage, currency) and
live financial state (balance, equity, margin).
| ATTRIBUTE | DESCRIPTION |
|---|---|
login |
Account number.
TYPE:
|
trade_mode |
Account type (demo, contest, real) as an MT5 integer.
TYPE:
|
leverage |
Account leverage (e.g. 100 for 1:100).
TYPE:
|
limit_orders |
Maximum number of active pending orders allowed.
TYPE:
|
margin_so_mode |
Stop-out mode (percent or money) as an MT5 integer.
TYPE:
|
trade_allowed |
Whether trading is permitted on this account.
TYPE:
|
trade_expert |
Whether Expert Advisors are permitted to trade.
TYPE:
|
margin_mode |
Margin calculation mode as an MT5 integer.
TYPE:
|
currency_digits |
Number of decimal places for the account currency.
TYPE:
|
fifo_close |
Whether positions must be closed in FIFO order.
TYPE:
|
balance |
Account balance in account currency.
TYPE:
|
credit |
Credit facility amount.
TYPE:
|
profit |
Current floating profit/loss across all open positions.
TYPE:
|
equity |
Effective account value (balance + profit + credit).
TYPE:
|
margin |
Margin currently in use.
TYPE:
|
margin_free |
Free margin available for new positions.
TYPE:
|
margin_level |
Margin level as a percentage (equity / margin * 100).
TYPE:
|
margin_so_call |
Margin call level (percent or money, per
TYPE:
|
margin_so_so |
Stop-out level (percent or money, per
TYPE:
|
margin_initial |
Initial margin requirement.
TYPE:
|
margin_maintenance |
Maintenance margin requirement.
TYPE:
|
assets |
Total assets.
TYPE:
|
liabilities |
Total liabilities.
TYPE:
|
commission_blocked |
Commission reserved for open positions.
TYPE:
|
name |
Account holder name.
TYPE:
|
server |
Broker server name.
TYPE:
|
currency |
Account currency code (e.g.
TYPE:
|
company |
Broker company name.
TYPE:
|
margin_used_percent
property
¶
Margin in use as a percentage of equity.
Returns 0.0 when equity is zero to avoid division by zero.
| RETURNS | DESCRIPTION |
|---|---|
float
|
Margin usage percentage (0โ100+). |
equity_to_balance_ratio
property
¶
Ratio of equity to balance, indicating unrealised P&L impact.
A value above 1.0 means open positions are in profit; below 1.0 means they are in loss. Returns 0.0 when balance is zero.
| RETURNS | DESCRIPTION |
|---|---|
float
|
Equity / balance ratio. |
Service¶
AccountService¶
AccountService
¶
Retrieves trading account information from the MT5 terminal.
Wraps mt5.account_info() via call_mt5, parses the raw
AccountInfo struct into a typed model, and returns
Result[AccountInfo].