2026-06-26 03:08:57 +00:00
|
|
|
{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"mt5cli \u00b6 Generic MT5 data and execution infrastructure for Python applications. Overview \u00b6 mt5cli provides a stable MT5Client Python API, standardized dataset schemas, storage helpers, and a CLI for exporting MetaTrader 5 data. It is built on top of pdmt5 , a pandas-based data handler for MetaTrader 5. Architecture \u00b6 pdmt5 \u2014 canonical MT5 client, DataFrame/trading primitives, and MT5 constant parsing ( TIMEFRAME_* , COPY_TICKS_* , order types). mt5cli \u2014 public MT5Client API, schema contracts, storage helpers, CLI commands, and SQLite history collection built on pdmt5. mt5api \u2014 sibling HTTP adapter for remote MT5 access; not a dependency of mt5cli. Features \u00b6 Multi-format export : CSV, JSON, Parquet, and SQLite3 output formats Auto-detection : Format detection from file extensions Comprehensive data access : Rates, ticks, account info, symbols, orders, positions, and trading history Flexible timeframes : Named timeframes (M1, H1, D1, etc.) and numeric values Connection management : Optional credentials, server, and timeout configuration SQLite rate loading : Load mt5cli-managed rate tables/views for offline workflows Installation \u00b6 pip install mt5cli Parquet export is not included by default. To enable it, install the parquet extra: pip install \"mt5cli[parquet]\" Python API for downstream packages \u00b6 Import MT5Client for generic MT5 data access, schema normalization, and optional order primitives. from datetime import UTC , datetime from pathlib import Path from mt5cli import ( DataKind , Dataset , MT5Client , build_config , collect_history , export_dataframe , load_rate_data , minimum_margins , mt5_session , normalize_dataframe , recent_ticks , resolve_rate_view_name , ) # Persistent session for multiple calls with mt5_session ( build_config ( login = 12345 , server = \"Broker-Demo\" )) as client : rates = client . copy_rates_range ( \"EURUSD\" , timeframe = \"H1\" , date_from = \"2024-01-01\" , date_to = \"2024-02-01\" , ) positions = client . positions () check = client . order_check ({ \"action\" : 1 , \"symbol\" : \"EURUSD\" , \"volume\" : 0.1 }) # Normalize MT5 frames to the public schema contract before storage closed_rates = normalize_dataframe ( rates , DataKind . rates , symbol = \"EURUSD\" , timeframe = \"H1\" ) export_dataframe ( closed_rates , Path ( \"rates.csv\" ), \"csv\" ) # Offline rate loading from mt5cli-managed SQLite history view = resolve_rate_view_name ( Path ( \"history.db\" ), \"EURUSD\" , \"M1\" , require_existing = True ) offline_rates = load_rate_data ( Path ( \"history.db\" ), view , count = 1000 ) # One-off helpers still work without instantiating a client ticks = recent_ticks ( \"EURUSD\" , seconds = 300 ) margins = minimum_margins ( \"EURUSD\" ) collect_history ( Path ( \"history.db\" ), symbols = [ \"EURUSD\" , \"GBPUSD\" ], date_from = datetime ( 2024 , 1 , 1 , tzinfo = UTC ), date_to = datetime ( 2024 , 2 , 1 , tzinfo = UTC ), datasets = { Dataset . rates , Dataset . history_deals }, ) Schema contracts live in mt5cli.schemas ( DataKind , validate_schema , normalize_dataframe ). Storage helpers are re-exported from mt5cli.storage and the package root. MT5Client.order_send() is a live execution primitive: it can place real trades on the connected account. mt5cli does not implement strategy logic, signal generation, backtesting, or optimization \u2014 downstream applications must gate live execution explicitly (the CLI requires --yes for order-send ). MT5Client.mt5_summary() returns structured nested Python values. Use MT5Client.mt5_summary_as_df() when you need a one-row DataFrame for export. Quick Start \u00b6 # Export account information to CSV mt5cli -o account.csv account-info # Export EURUSD M1 rates to Parquet mt5cli -o rates.parquet rates-from --symbol EURUSD --timeframe M1 \\ --date-from 2024 -01-01 --count 1000 # Export ticks to JSON mt5cli -o ticks.json ticks-from --symbol EURUSD \\ --date-fr
|