Getting an Account Summary (info
) π¶
What it Does¶
Fetches real-time account snapshot from MT5 and prints it either in text (console) or JSON (machine-readable). Used for checking account state, verifying connectivity, and quick diagnostics.
Method Signature¶
public Task<AccountSummaryData> AccountSummaryAsync(
DateTime? deadline = null,
CancellationToken cancellationToken = default
)
¶
public Task<AccountSummaryData> AccountSummaryAsync(
DateTime? deadline = null,
CancellationToken cancellationToken = default
)
Code Reference π§©¶
// --- Quick use (service wrapper) ---
// Prints account summary info in a single call.
var summary = await _mt5Account.AccountSummaryAsync();
_logger.LogInformation("=== Account Info ===");
_logger.LogInformation("Login: {0}", summary.AccountLogin);
_logger.LogInformation("Balance: {0}", summary.AccountBalance);
_logger.LogInformation("Equity: {0}", summary.AccountEquity);
// ... prints leverage, trade mode, margin, free margin, etc.
// --- Low-level (direct call with retry and cancellation) ---
// Preconditions: connection is already established.
using var opCts = new CancellationTokenSource(TimeSpan.FromSeconds(3));
ct => _mt5Account.AccountSummaryAsync(deadline: null, cancellationToken: ct),
opCts.Token
);
Console.WriteLine($"Login: {summary.AccountLogin}, Balance: {summary.AccountBalance}");
Input Parameters β¬οΈ¶
Parameter | Type | Required | Description |
---|---|---|---|
--profile |
string | yes | Which profile to use (from profiles.json β holds login, server, password). |
--output |
string | no | Output format: text (default) or json . |
--timeout-ms |
int | no | Per-RPC timeout in milliseconds (default: 30000). |
Output Fields β¬οΈ¶
Printed from AccountSummaryData
+ extra info via AccountInformation
:
Field | Type | Description |
---|---|---|
Login |
int64 | Account ID (login). |
UserName |
string | Account holderβs name. |
Currency |
string | Deposit currency (e.g. USD, EUR). |
Balance |
double | Current balance excluding open P/L. |
Equity |
double | Balance including floating P/L. |
Leverage |
int | Account leverage (e.g. 500). |
TradeMode |
enum | Account trade mode (e.g. Demo/Real). |
Company |
string | Broker name. |
Margin |
double | Currently used margin. |
FreeMargin |
double | Margin still available for trading. |
ServerTime |
DateTime | Server time in UTC. |
UTC Shift |
int | Timezone offset in minutes. |
How to Use π οΈ¶
Full CLI¶
dotnet run -- info -p demo --output json --timeout-ms 90000
PowerShell Shortcuts (from ps/shortcasts.ps1
)¶
. .\ps\shortcasts.ps1
use-pf demo
use-to 90000
info
use-pf demo
β choose profiledemo
once.use-to 90000
β set default timeout (ms).info
β expands tomt5 info -p demo --timeout-ms 90000
.
When to Use β¶
- Before sending orders β check equity, free margin, leverage.
- Monitoring β feed JSON into dashboards, CI/CD or alerts.
- Diagnostics β confirm MT5 terminal is connected and profile credentials work.
- Risk control β margin usage visible before high-risk trades.