Client¶
mt5cli.client ¶
Stable public client abstraction for MT5 data and execution operations.
MT5Client ¶
MT5Client(
*,
path: str | None = None,
login: int | None = None,
password: str | None = None,
server: str | None = None,
timeout: int | None = None,
retry_count: int = 3,
config: Mt5Config | None = None,
client: Mt5DataClient | None = None,
)
Bases: Mt5CliClient
Public client for generic MT5 data access and order primitives.
Extends the read-only SDK client with optional order check/send helpers and
exposes the same connection lifecycle as :class:~mt5cli.sdk.Mt5CliClient.
Downstream applications such as private trading packages should prefer this
type over the legacy Mt5CliClient name.
mt5cli intentionally exposes minimal execution primitives only. Trading decisions, signals, strategies, backtests, and optimization remain the responsibility of downstream applications.
Source code in mt5cli/sdk.py
from_connected_client
classmethod
¶
Bind to an already-connected Mt5DataClient without owning it.
Returns:
| Type | Description |
|---|---|
Self
|
Client wrapper bound to the injected connection. |
order_check ¶
Check funds sufficiency for a trade request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
dict[str, Any]
|
MT5 order request dictionary. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
One-row DataFrame with the order-check result. |
Source code in mt5cli/client.py
order_send ¶
Send a live trade request to the MT5 trade server.
Warning
This is a live execution primitive. A successful call can place, modify, or close real trades on the connected account. Downstream applications must gate usage explicitly (for example behind manual confirmation or application-specific risk controls). mt5cli does not implement strategy logic, signal generation, or trade sizing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
dict[str, Any]
|
MT5 order request dictionary. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
One-row DataFrame with the order-send result. |
Source code in mt5cli/client.py
build_config ¶
build_config(
*,
path: str | None = None,
login: int | None = None,
password: str | None = None,
server: str | None = None,
timeout: int | None = None,
) -> Mt5Config
Build an Mt5Config from optional connection parameters.
Returns:
| Type | Description |
|---|---|
Mt5Config
|
Configured |
Source code in mt5cli/sdk.py
mt5_session ¶
mt5_session(
config: Mt5Config | None = None,
) -> Iterator[MT5Client]
Open an MT5 terminal session and yield a connected :class:MT5Client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Mt5Config | None
|
MT5 connection configuration. Defaults to an empty config that attaches to a running terminal. |
None
|
Yields:
| Name | Type | Description |
|---|---|---|
Connected |
MT5Client
|
class: |