mt5cli 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mt5cli-0.3.0 → mt5cli-0.4.0}/AGENTS.md +3 -1
- {mt5cli-0.3.0 → mt5cli-0.4.0}/PKG-INFO +1 -1
- {mt5cli-0.3.0 → mt5cli-0.4.0}/docs/api/index.md +39 -6
- mt5cli-0.4.0/docs/api/sdk.md +3 -0
- mt5cli-0.4.0/docs/api/utils.md +3 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/docs/index.md +41 -1
- {mt5cli-0.3.0 → mt5cli-0.4.0}/mkdocs.yml +2 -0
- mt5cli-0.4.0/mt5cli/__init__.py +56 -0
- mt5cli-0.4.0/mt5cli/cli.py +612 -0
- mt5cli-0.4.0/mt5cli/sdk.py +1023 -0
- mt5cli-0.4.0/mt5cli/utils.py +408 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/pyproject.toml +1 -5
- {mt5cli-0.3.0 → mt5cli-0.4.0}/tests/test_cli.py +12 -316
- mt5cli-0.4.0/tests/test_sdk.py +466 -0
- mt5cli-0.4.0/tests/test_utils.py +335 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/uv.lock +1 -1
- mt5cli-0.3.0/mt5cli/__init__.py +0 -12
- mt5cli-0.3.0/mt5cli/cli.py +0 -1452
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.agents/skills/local-qa/SKILL.md +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.agents/skills/local-qa/scripts/qa.sh +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.agents/skills/mt5cli/SKILL.md +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.claude/agents/codex.md +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.claude/settings.json +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.github/FUNDING.yml +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.github/dependabot.yml +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.github/renovate.json +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.github/workflows/ci.yml +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.github/workflows/claude.yml +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.github/workflows/release.yml +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/.gitignore +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/CLAUDE.md +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/LICENSE +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/README.md +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/docs/api/cli.md +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/mt5cli/__main__.py +0 -0
- {mt5cli-0.3.0 → mt5cli-0.4.0}/tests/__init__.py +0 -0
|
@@ -29,9 +29,11 @@ uv sync
|
|
|
29
29
|
- `mt5cli/`: Main package directory
|
|
30
30
|
- `__init__.py`: Package initialization and exports (`detect_format`, `export_dataframe`)
|
|
31
31
|
- `cli.py`: CLI application with typer-based commands for data export
|
|
32
|
+
- `utils.py`: Constants, enums, parameter types, parsers, and export utilities
|
|
32
33
|
- `__main__.py`: Entry point for `python -m mt5cli`
|
|
33
34
|
- `tests/`: Comprehensive test suite (pytest-based)
|
|
34
|
-
- `test_cli.py`: Tests for CLI commands
|
|
35
|
+
- `test_cli.py`: Tests for CLI commands and collect-history behavior
|
|
36
|
+
- `test_utils.py`: Tests for utility constants, parameter types, parsers, and export functions
|
|
35
37
|
- `docs/`: MkDocs documentation with API reference
|
|
36
38
|
- `docs/index.md`: Main documentation
|
|
37
39
|
- `docs/api/`: Auto-generated API documentation for all modules
|
|
@@ -10,12 +10,22 @@ The mt5cli package consists of the following modules:
|
|
|
10
10
|
|
|
11
11
|
Command-line interface module providing typer-based commands for exporting MetaTrader 5 data to CSV, JSON, Parquet, and SQLite3 formats.
|
|
12
12
|
|
|
13
|
+
### [Utils](utils.md)
|
|
14
|
+
|
|
15
|
+
Utility module providing constants, enums, Click parameter types, and helper functions for parsing and exporting data.
|
|
16
|
+
|
|
17
|
+
### [SDK](sdk.md)
|
|
18
|
+
|
|
19
|
+
Programmatic SDK for read-only MetaTrader 5 data collection. Returns pandas DataFrames and provides `collect_history` for SQLite bulk collection.
|
|
20
|
+
|
|
13
21
|
## Architecture Overview
|
|
14
22
|
|
|
15
23
|
The package follows a simple architecture built on top of pdmt5:
|
|
16
24
|
|
|
17
|
-
1. **CLI Layer** (`cli.py`): Typer application with subcommands
|
|
18
|
-
2. **
|
|
25
|
+
1. **CLI Layer** (`cli.py`): Typer application with subcommands that delegate to the SDK and export results.
|
|
26
|
+
2. **SDK Layer** (`sdk.py`): Read-only data access functions, `Mt5CliClient`, and `collect_history` orchestration.
|
|
27
|
+
3. **Utils Layer** (`utils.py`): Constants, enums, custom Click parameter types, parsing helpers, and format detection/export utilities.
|
|
28
|
+
4. **Data Layer** (via `pdmt5`): Uses `Mt5DataClient` and `Mt5Config` from the pdmt5 package for all MetaTrader 5 data access.
|
|
19
29
|
|
|
20
30
|
## Usage Guidelines
|
|
21
31
|
|
|
@@ -47,15 +57,38 @@ mt5cli -o data.db --table symbols symbols --group "*USD*"
|
|
|
47
57
|
## Python API
|
|
48
58
|
|
|
49
59
|
```python
|
|
50
|
-
from
|
|
51
|
-
|
|
60
|
+
from datetime import UTC, datetime
|
|
61
|
+
from pathlib import Path
|
|
62
|
+
|
|
63
|
+
from mt5cli import (
|
|
64
|
+
Mt5CliClient,
|
|
65
|
+
collect_history,
|
|
66
|
+
copy_rates_range,
|
|
67
|
+
detect_format,
|
|
68
|
+
export_dataframe,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Fetch rates programmatically
|
|
72
|
+
rates = copy_rates_range(
|
|
73
|
+
"EURUSD",
|
|
74
|
+
timeframe="H1",
|
|
75
|
+
date_from="2024-01-01",
|
|
76
|
+
date_to="2024-02-01",
|
|
77
|
+
)
|
|
52
78
|
|
|
53
79
|
# Detect output format from file extension
|
|
54
80
|
fmt = detect_format(Path("output.parquet")) # Returns "parquet"
|
|
55
81
|
|
|
56
82
|
# Export a DataFrame
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
export_dataframe(rates, Path("output.csv"), "csv")
|
|
84
|
+
|
|
85
|
+
# Collect history into SQLite
|
|
86
|
+
collect_history(
|
|
87
|
+
Path("history.db"),
|
|
88
|
+
symbols=["EURUSD"],
|
|
89
|
+
date_from=datetime(2024, 1, 1, tzinfo=UTC),
|
|
90
|
+
date_to=datetime(2024, 2, 1, tzinfo=UTC),
|
|
91
|
+
)
|
|
59
92
|
```
|
|
60
93
|
|
|
61
94
|
## Examples
|
|
@@ -20,6 +20,44 @@ mt5cli is a CLI application that exports MetaTrader 5 trading data to multiple f
|
|
|
20
20
|
pip install mt5cli
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## Programmatic usage / SDK usage
|
|
24
|
+
|
|
25
|
+
mt5cli can be used as a small Python SDK for read-only MetaTrader 5 data collection. SDK functions return pandas DataFrames without writing files. Use `export_dataframe` when you need to persist results.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from datetime import UTC, datetime
|
|
29
|
+
from pathlib import Path
|
|
30
|
+
|
|
31
|
+
from mt5cli import Mt5CliClient, collect_history, copy_rates_range, export_dataframe
|
|
32
|
+
|
|
33
|
+
# One-off fetch with module-level helpers
|
|
34
|
+
rates = copy_rates_range(
|
|
35
|
+
"EURUSD",
|
|
36
|
+
timeframe="H1",
|
|
37
|
+
date_from="2024-01-01",
|
|
38
|
+
date_to="2024-02-01",
|
|
39
|
+
)
|
|
40
|
+
export_dataframe(rates, Path("rates.csv"), "csv")
|
|
41
|
+
|
|
42
|
+
# Reuse one MT5 connection for multiple calls
|
|
43
|
+
with Mt5CliClient(login=12345, password="secret", server="Broker-Demo") as client:
|
|
44
|
+
account = client.account_info()
|
|
45
|
+
positions = client.positions()
|
|
46
|
+
|
|
47
|
+
# Bulk SQLite collection (same behavior as the collect-history CLI command)
|
|
48
|
+
collect_history(
|
|
49
|
+
Path("history.db"),
|
|
50
|
+
symbols=["EURUSD", "GBPUSD"],
|
|
51
|
+
date_from=datetime(2024, 1, 1, tzinfo=UTC),
|
|
52
|
+
date_to=datetime(2024, 2, 1, tzinfo=UTC),
|
|
53
|
+
timeframe="M1",
|
|
54
|
+
flags="ALL",
|
|
55
|
+
with_views=True,
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Timeframes, tick flags, and ISO 8601 date strings are accepted wherever noted in the SDK API.
|
|
60
|
+
|
|
23
61
|
## Quick Start
|
|
24
62
|
|
|
25
63
|
```bash
|
|
@@ -138,7 +176,9 @@ History orders and deals are fetched per symbol and concatenated, so the symbol
|
|
|
138
176
|
|
|
139
177
|
Browse the API documentation for detailed module information:
|
|
140
178
|
|
|
141
|
-
- [CLI Module](api/cli.md) - CLI application with export commands
|
|
179
|
+
- [CLI Module](api/cli.md) - CLI application with export commands
|
|
180
|
+
- [SDK Module](api/sdk.md) - Programmatic read-only data collection API
|
|
181
|
+
- [Utils Module](api/utils.md) - Constants, parameter types, parsers, and export utilities
|
|
142
182
|
|
|
143
183
|
## Development
|
|
144
184
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""mt5cli: Command-line tool and SDK for MetaTrader 5."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import version
|
|
4
|
+
|
|
5
|
+
from .sdk import (
|
|
6
|
+
Mt5CliClient,
|
|
7
|
+
account_info,
|
|
8
|
+
build_config,
|
|
9
|
+
collect_history,
|
|
10
|
+
copy_rates_from,
|
|
11
|
+
copy_rates_from_pos,
|
|
12
|
+
copy_rates_range,
|
|
13
|
+
copy_ticks_from,
|
|
14
|
+
copy_ticks_range,
|
|
15
|
+
history_deals,
|
|
16
|
+
history_orders,
|
|
17
|
+
last_error,
|
|
18
|
+
market_book,
|
|
19
|
+
orders,
|
|
20
|
+
positions,
|
|
21
|
+
symbol_info,
|
|
22
|
+
symbol_info_tick,
|
|
23
|
+
symbols,
|
|
24
|
+
terminal_info,
|
|
25
|
+
)
|
|
26
|
+
from .sdk import (
|
|
27
|
+
version as mt5_version,
|
|
28
|
+
)
|
|
29
|
+
from .utils import detect_format, export_dataframe
|
|
30
|
+
|
|
31
|
+
__version__ = version(__package__) if __package__ else None
|
|
32
|
+
|
|
33
|
+
__all__ = [
|
|
34
|
+
"Mt5CliClient",
|
|
35
|
+
"account_info",
|
|
36
|
+
"build_config",
|
|
37
|
+
"collect_history",
|
|
38
|
+
"copy_rates_from",
|
|
39
|
+
"copy_rates_from_pos",
|
|
40
|
+
"copy_rates_range",
|
|
41
|
+
"copy_ticks_from",
|
|
42
|
+
"copy_ticks_range",
|
|
43
|
+
"detect_format",
|
|
44
|
+
"export_dataframe",
|
|
45
|
+
"history_deals",
|
|
46
|
+
"history_orders",
|
|
47
|
+
"last_error",
|
|
48
|
+
"market_book",
|
|
49
|
+
"mt5_version",
|
|
50
|
+
"orders",
|
|
51
|
+
"positions",
|
|
52
|
+
"symbol_info",
|
|
53
|
+
"symbol_info_tick",
|
|
54
|
+
"symbols",
|
|
55
|
+
"terminal_info",
|
|
56
|
+
]
|