Public API Contract

-

mt5cli is the generic MT5 data and execution infrastructure layer for downstream -Python applications. The intended dependency direction is:

+

mt5cli is the canonical operational trading SDK and CLI/batch layer over pdmt5. +The intended dependency direction is:

downstream app -> mt5cli -> pdmt5 -> MetaTrader 5
 
+

Responsibility boundary

+ + + + + + + + + + + + + + + + + + + + + +
LayerOwns
pdmt5MT5 core wrapper; DataFrame/dict conversion; canonical MT5 constants and parsers; direct low-level order primitives
mt5cliCLI/batch workflows; SQLite history collection; normalized datasets; closed-bar helpers; small downstream operational SDK; generic broker-facing margin/volume/order orchestration
downstreamStrategy logic; signals; risk policy; backtesting; optimization; YAML/application semantics
+

Downstream code should import raw pdmt5 types and constants (such as +Mt5Config, Mt5TradingClient, Mt5RuntimeError, Mt5TradingError, +TIMEFRAME_MAP, COPY_TICKS_MAP) directly from pdmt5 when needed. +mt5cli does not serve as a pass-through compatibility namespace for pdmt5.

+

Note: the former mt5cli re-export TICK_FLAG_MAP corresponds to COPY_TICKS_MAP +in pdmt5 — the name changed, it was not simply moved.

Downstream packages should import from the package root (from mt5cli import ...) and use the public tier sets in mt5cli.contract to distinguish API stability. CLI commands mirror the same behavior but are not importable Python @@ -448,7 +481,7 @@ after price movement and does not inspect trade_freeze_level. Live sending requests. Failed, malformed, or unknown broker retcodes are fail-closed and returned as status="failed" with normalized request / response details; dry_run=True never calls ensure_symbol_selected() or order_send().

-

Errors and MT5 type re-exports

+

Errors

@@ -465,10 +498,6 @@ and returned as status="failed" with normalized requestnormalize_mt5_exception, call_with_normalized_errors, is_recoverable_mt5_error - - - -
Error normalization and retry classification
Mt5Config, Mt5RuntimeError, Mt5TradingClient, Mt5TradingErrorRe-exported pdmt5 types for adapter convenience

Secondary public exports

@@ -548,7 +577,7 @@ the MT5 SDK helper.