β Symbols Total¶
Request: get the total number of symbols on the server, with an option to count only Market Watch (selected) symbols.
Source files:
MetaRpcMT5/mt5_account.py
β methodsymbols_total(...)
MetaRpcMT5/mt5_term_api_market_info_pb2.py
βSymbolsTotal*
messages (SymbolsTotalRequest
,SymbolsTotalReply
,SymbolsTotalData
)MetaRpcMT5/mt5_term_api_market_info_pb2_grpc.py
β service stubMarketInfoStub
Note (verified):
SymbolsTotal*
exist only inmt5_term_api_market_info_pb2.py
. The request field ismode: bool
; the reply data hastotal: int32
.
RPC¶
- Service:
mt5_term_api.MarketInfo
- Method:
SymbolsTotal(SymbolsTotalRequest) β SymbolsTotalReply
- Low-level client:
MarketInfoStub.SymbolsTotal(request, metadata, timeout)
- SDK wrapper:
MT5Account.symbols_total(selected_only, deadline=None, cancellation_event=None)
π Code Example¶
# Count only symbols that are in Market Watch
from MetaRpcMT5 import mt5_term_api_market_info_pb2 as mi_pb2
total = await acct.symbols_total(selected_only=True)
print(total.total) # integer count
Method Signature¶
async def symbols_total(
self,
selected_only: bool,
deadline: datetime | None = None,
cancellation_event: asyncio.Event | None = None,
) -> market_info_pb2.SymbolsTotalData
π¬ Plain English¶
- What it is. A tiny, cheap call that returns how many symbols are available.
- Why you care. Useful for sanity checks, monitoring, and UI decisions (e.g., pagination, lazy loading).
-
Mind the traps.
-
selected_only=True
counts only the symbols in Market Watch.False
counts all known symbols. - The SDK returns
.data
from the reply; youβll get aSymbolsTotalData
object with a singletotal
field.
π½ Input¶
Parameter | Type | Description | ||
---|---|---|---|---|
selected_only |
bool (required) |
True β count only Market Watch; False β all. |
||
deadline |
`datetime | None` | Absolute per-call deadline β converted to timeout. | |
cancellation_event |
`asyncio.Event | None` | Cooperative cancel for the retry wrapper. |
β¬οΈ Output¶
Payload: SymbolsTotalData
¶
Field | Proto Type | Description |
---|---|---|
total |
int32 |
The resulting symbol count. |
Wire reply:
SymbolsTotalReply { data: SymbolsTotalData, error: Error? }
SDK returnsreply.data
.
See also: symbol_name.md, symbol_exist.md, symbol_select.md
π― Purpose¶
- Fast check for how big the symbol universe is (all vs. Market Watch).
- Drive UI/UX (e.g., disable βShow Allβ if counts are huge).
- Monitor environment changes (e.g., sudden drop in selected symbols).
π§© Notes & Tips¶
- Prefer
selected_only=True
for user-facing views (keeps counts relevant to what the user actually sees). - For inventory/ops dashboards, do both (selected & all) to compare deltas.
- Wrapper uses
execute_with_reconnect(...)
β transient gRPC hiccups are retried under the hood.
Usage Examples¶
1) Count all symbols¶
all_total = await acct.symbols_total(selected_only=False)
print(f"All symbols: {all_total.total}")
2) Count selected (Market Watch) with deadline & cancel¶
import asyncio
from datetime import datetime, timedelta, timezone
cancel_event = asyncio.Event()
sel_total = await acct.symbols_total(
selected_only=True,
deadline=datetime.now(timezone.utc) + timedelta(seconds=2),
cancellation_event=cancel_event,
)
print(f"Selected symbols: {sel_total.total}")
3) Compare selected vs. all¶
selected = await acct.symbols_total(True)
all_ = await acct.symbols_total(False)
print(f"{selected.total}/{all_.total} symbols in Market Watch")