Description
get_account_type() in metatrader_client/account/get_account_type.py has
all three trade_mode → account_type mappings inverted.
Current code (v0.5.1)
# metatrader_client/account/get_account_type.py
def get_account_type(connection) -> str:
account_info = get_account_info(connection)
trade_mode = account_info["trade_mode"]
if trade_mode == 0:
return "real"
elif trade_mode == 1:
return "demo"
elif trade_mode == 2:
return "contest"
else:
return f"unknown ({trade_mode})"
Expected behavior
MT5 Python API defines ACCOUNT_TRADE_MODE as:
- 0 =
ACCOUNT_TRADE_MODE_DEMO
- 1 =
ACCOUNT_TRADE_MODE_CONTEST
- 2 =
ACCOUNT_TRADE_MODE_REAL
(Source: MetaTrader5 Python docs)
Observed vs expected
| trade_mode |
MT5 meaning |
Package returns |
Correct |
| 0 |
DEMO |
\real\ |
\demo\ |
| 1 |
CONTEST |
\demo\ |
\contest\ |
| 2 |
REAL |
\contest\ |
\real\ |
Impact
- Demo accounts are reported as
"real" in get_trade_statistics() / get_account_info() MCP tool responses
- Real accounts would be reported as
"contest"
- All downstream consumers using
account_type to make decisions get the wrong signal
Fix
def get_account_type(connection) -> str:
account_info = get_account_info(connection)
trade_mode = account_info["trade_mode"]
if trade_mode == 0:
return "demo"
elif trade_mode == 1:
return "contest"
elif trade_mode == 2:
return "real"
else:
return f"unknown ({trade_mode})"
Also note: the docstring in get_account_info.py line 12 also has a wrong mapping:
- trade_mode: Account trade mode (0-real, 1-demo, 2-contest)
This should be 0-demo, 1-contest, 2-real.
Discovered while running metatrader-mcp-server against a MetaQuotes-Demo
account — get_account_info returned "account_type": "real" despite
the account being demo.
Description
get_account_type()inmetatrader_client/account/get_account_type.pyhasall three
trade_mode→account_typemappings inverted.Current code (v0.5.1)
Expected behavior
MT5 Python API defines
ACCOUNT_TRADE_MODEas:ACCOUNT_TRADE_MODE_DEMOACCOUNT_TRADE_MODE_CONTESTACCOUNT_TRADE_MODE_REAL(Source: MetaTrader5 Python docs)
Observed vs expected
Impact
"real"inget_trade_statistics()/get_account_info()MCP tool responses"contest"account_typeto make decisions get the wrong signalFix
Also note: the docstring in
get_account_info.pyline 12 also has a wrong mapping:This should be
0-demo, 1-contest, 2-real.Discovered while running
metatrader-mcp-serveragainst aMetaQuotes-Demoaccount —
get_account_inforeturned"account_type": "real"despitethe account being demo.