# MT5 Python account_info()

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/platforms/metatrader-5/functions/python-account-info, written from the same records as that page.

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Returns everything the terminal holds about the trading account it is logged in to, in one call.

- Function: `account_info()`
- Interface: MetaTrader5 Python package
- Group: Account
- Status: verified. Source: [mql5.com](https://www.mql5.com/en/docs/python_metatrader5/mt5accountinfo_py), checked 2026-10-12.

This is a Python function, not an HTTP endpoint. It has no method, no path and no address to send a request to: the package talks to a MetaTrader 5 terminal running on the same computer. It is in no OpenAPI file on this site and the request builder does not list it.

Note: The package works on one account at a time, the one the terminal is logged in to. There is no call that lists several accounts.

## Signature

The form of the call on the vendor's page, with the vendor's comments taken out.

```python
account_info()
```

## Arguments

The function takes no arguments.

## Return value

- Type: `namedtuple or None`
- What comes back: A named tuple of the account's properties. The page says it holds everything AccountInfoInteger, AccountInfoDouble and AccountInfoString return in MQL5. On failure the page says it returns None, and that last_error() gives the reason.

## Sample

Written by this site from the signature and arguments recorded on this page. It has not been run against a terminal, a server or an account, and the values in it are placeholders. No credential is typed into it: where one is needed it is read from an environment variable on your own machine. Nothing is entered on this site.

```python
import MetaTrader5 as mt5

if not mt5.initialize():
    raise SystemExit(f"initialize() failed: {mt5.last_error()}")

account = mt5.account_info()
if account is None:
    print("account_info() failed:", mt5.last_error())
else:
    print(account.balance, account.equity, account.margin_free)

mt5.shutdown()
```

## More on MetaTrader 5

- [All MetaTrader 5 functions](https://openbrokerapi.com/platforms/metatrader-5/functions): 78 documented here, grouped by what they do.
- [List accounts: the call at each API](https://openbrokerapi.com/endpoints/accounts): The same job at every broker and platform API recorded here, HTTP or not.
- [MetaTrader 5 API quickstart](https://openbrokerapi.com/platforms/metatrader-5/quickstart)
- [All MetaTrader 5 error codes](https://openbrokerapi.com/errors/mt5)
- [MetaTrader 5 API page](https://openbrokerapi.com/platforms/metatrader-5): The full record: access, authentication, limits and the source for each.

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: MT5 Python account_info(). Broker API Hub, https://openbrokerapi.com/platforms/metatrader-5/functions/python-account-info, newest check 2026-10-12.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
