Skip to content

Release v0.8.0

Choose a tag to compare

@cloudQuant cloudQuant released this 20 Mar 03:46
· 7 commits to master since this release

v0.8.0 — Major Refactor: Mixin Architecture, Custom Exceptions, 99% Coverage

Architecture Overhaul

Split monolithic client.py (3,473 lines) into focused mixin modules:

Module Responsibility Lines
_account.py Account info, password, demo/real account opening, OTP ~400
_market_data.py Symbols, ticks, bars, subscriptions, order book ~460
_trading.py Orders, positions, deals, trade history, validation ~400
_push_handlers.py Push notification registration & dispatch ~200
_parsers.py Standalone binary parsing functions ~500
_validation.py Input validation helpers ~20
exceptions.py Custom exception hierarchy ~10
types.py Dataclasses, TypedDicts, type aliases ~180
client.py Core lifecycle + mixin assembly ~220

MT5WebClient remains the single public API — fully backward compatible.

Custom Exception Hierarchy

PyMT5Error
├── MT5ConnectionError
├── AuthenticationError
├── TradeError (also inherits ValueError)
├── ProtocolError
├── SymbolNotFoundError (also inherits KeyError)
├── ValidationError (also inherits ValueError)
├── SessionError (also inherits RuntimeError)
└── MT5TimeoutError

Bug Fix

Fixed critical MRO method shadowing bug where mixin type-hint stubs (def method(): ...) were overriding real implementations at runtime, causing get_positions_and_orders() and related methods to silently return None.

Test Coverage

  • 788 tests, all passing on Python 3.11/3.12/3.13 across Linux, macOS, Windows
  • 99% overall coverage (25 uncovered lines across 16 files)
  • New test files: test_trading_coverage.py, test_market_data_coverage.py, test_client_lifecycle.py, test_transport_lifecycle.py, test_push_handlers.py, test_remaining_coverage.py, test_validation.py

Other Improvements

  • Input validation for trading methods (volume, price, symbol name)
  • Error handling examples in all 8 example scripts
  • Updated CLAUDE.md architecture documentation
  • Code formatting with ruff