mt5cli 0.2.0__tar.gz → 0.3.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/.agents/skills/local-qa/SKILL.md +22 -0
- mt5cli-0.3.0/.agents/skills/local-qa/scripts/qa.sh +26 -0
- mt5cli-0.3.0/.agents/skills/mt5cli/SKILL.md +113 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/.github/workflows/ci.yml +1 -2
- {mt5cli-0.2.0 → mt5cli-0.3.0}/PKG-INFO +37 -22
- {mt5cli-0.2.0 → mt5cli-0.3.0}/README.md +36 -21
- {mt5cli-0.2.0 → mt5cli-0.3.0}/docs/index.md +36 -7
- {mt5cli-0.2.0 → mt5cli-0.3.0}/mt5cli/cli.py +553 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/pyproject.toml +1 -1
- {mt5cli-0.2.0 → mt5cli-0.3.0}/tests/test_cli.py +609 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/uv.lock +10 -10
- mt5cli-0.2.0/.agents/skills/local-qa/SKILL.md +0 -25
- mt5cli-0.2.0/.agents/skills/local-qa/scripts/qa.sh +0 -19
- mt5cli-0.2.0/.agents/skills/mt5cli/SKILL.md +0 -104
- {mt5cli-0.2.0 → mt5cli-0.3.0}/.claude/agents/codex.md +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/.claude/settings.json +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/.github/FUNDING.yml +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/.github/dependabot.yml +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/.github/renovate.json +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/.github/workflows/claude.yml +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/.github/workflows/release.yml +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/.gitignore +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/AGENTS.md +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/CLAUDE.md +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/LICENSE +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/docs/api/cli.md +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/docs/api/index.md +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/mkdocs.yml +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/mt5cli/__init__.py +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/mt5cli/__main__.py +0 -0
- {mt5cli-0.2.0 → mt5cli-0.3.0}/tests/__init__.py +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: local-qa
|
|
3
|
+
description: Run local QA including formatting, linting, and testing for the repository. Use whenever any file has been updated.
|
|
4
|
+
disable-model-invocation: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Local QA (format, lint, and test)
|
|
8
|
+
|
|
9
|
+
Run the local QA script `scripts/qa.sh` in this skill.
|
|
10
|
+
|
|
11
|
+
## Procedure
|
|
12
|
+
|
|
13
|
+
- Execute the script exactly as shown above when this skill is triggered.
|
|
14
|
+
- Capture and summarize key output (success/failure, major warnings, and any files modified).
|
|
15
|
+
- If the script fails due to missing tooling (`command not found`, missing executable, or equivalent), install the missing tool(s) and rerun `./scripts/qa.sh`.
|
|
16
|
+
- Install tools using this order of preference:
|
|
17
|
+
1. Use the project's package manager when applicable (`uv`/`poetry` for Python, package manager scripts/dependencies for Node.js).
|
|
18
|
+
2. Use a system package manager (`brew` on macOS, `apt` on Debian/Ubuntu) when project-local install is not applicable.
|
|
19
|
+
3. Use language-specific installers as fallback (`pipx`/`pip`, `npm`, `go install`, etc.).
|
|
20
|
+
- If multiple tools are missing, repeat install -> rerun until QA completes or you hit a blocker.
|
|
21
|
+
- If installation fails or requires unavailable privileges, report what was attempted, the exact failure, and stop.
|
|
22
|
+
- Do not run unrelated commands; only run commands needed for QA and missing-tool installation.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -euox pipefail
|
|
4
|
+
cd "$(git rev-parse --show-toplevel)"
|
|
5
|
+
|
|
6
|
+
# Python
|
|
7
|
+
uv run ruff format .
|
|
8
|
+
uv run ruff check --fix .
|
|
9
|
+
uv run pyright .
|
|
10
|
+
uv run pytest
|
|
11
|
+
|
|
12
|
+
# Markdown
|
|
13
|
+
npx -y prettier --write './**/*.md'
|
|
14
|
+
|
|
15
|
+
# GitHub Actions
|
|
16
|
+
case "${OSTYPE}" in
|
|
17
|
+
darwin* | linux* )
|
|
18
|
+
zizmor --fix=safe .github/workflows
|
|
19
|
+
git ls-files -z -- '.github/workflows/*.yml' | xargs -0 -t actionlint
|
|
20
|
+
git ls-files -z -- '.github/workflows/*.yml' | xargs -0 -t yamllint -d '{"extends": "relaxed", "rules": {"line-length": "disable"}}'
|
|
21
|
+
checkov --framework=all --output=github_failed_only --directory=.
|
|
22
|
+
;;
|
|
23
|
+
* )
|
|
24
|
+
echo "GitHub Actions linting is only supported on Linux and macOS."
|
|
25
|
+
;;
|
|
26
|
+
esac
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mt5cli
|
|
3
|
+
description: Use the `mt5cli` CLI to export MetaTrader 5 data (rates, ticks, account, symbols, orders, positions, history) to CSV, JSON, Parquet, or SQLite3. Invoke when the user asks to export, dump, download, or fetch MT5 market data or account data to a file.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# mt5cli
|
|
7
|
+
|
|
8
|
+
Export MetaTrader 5 data to CSV, JSON, Parquet, or SQLite3 via the `mt5cli`
|
|
9
|
+
command. Output format is auto-detected from the file extension (`.csv`,
|
|
10
|
+
`.json`, `.parquet`/`.pq`, `.db`/`.sqlite`/`.sqlite3`) or overridden with
|
|
11
|
+
`--format/-f`.
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
- Python 3.11+ on Windows with MetaTrader 5 installed (pdmt5 requires the
|
|
16
|
+
MT5 terminal).
|
|
17
|
+
- Install: `pip install -U mt5cli MetaTrader5`.
|
|
18
|
+
- In this repo, run via `uv run mt5cli ...` or `uv run python -m mt5cli ...`.
|
|
19
|
+
|
|
20
|
+
## Invocation shape
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
mt5cli [GLOBAL OPTIONS] -o OUTPUT COMMAND [COMMAND OPTIONS]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Global options MUST precede the subcommand.
|
|
27
|
+
|
|
28
|
+
### Global options (apply to every subcommand)
|
|
29
|
+
|
|
30
|
+
| Option | Purpose |
|
|
31
|
+
| --------------------- | ------------------------------------------------------------- |
|
|
32
|
+
| `-o, --output PATH` | Output file path (required). |
|
|
33
|
+
| `-f, --format FORMAT` | `csv`, `json`, `parquet`, or `sqlite3` (auto from extension). |
|
|
34
|
+
| `--table NAME` | Table name for SQLite3 output (default: `data`). |
|
|
35
|
+
| `--login INT` | MT5 trading account login. |
|
|
36
|
+
| `--password TEXT` | MT5 trading account password. |
|
|
37
|
+
| `--server TEXT` | MT5 trading server name. |
|
|
38
|
+
| `--path TEXT` | Path to MetaTrader 5 terminal EXE. |
|
|
39
|
+
| `--timeout INT` | Connection timeout in milliseconds. |
|
|
40
|
+
| `--log-level LEVEL` | `DEBUG`, `INFO`, `WARNING` (default), `ERROR`. |
|
|
41
|
+
|
|
42
|
+
### Parameter value formats
|
|
43
|
+
|
|
44
|
+
- **Datetimes** (`--date-from`, `--date-to`): ISO 8601 (`2024-01-01` or
|
|
45
|
+
`2024-01-01T12:00:00+00:00`). Naive values are treated as UTC.
|
|
46
|
+
- **Timeframe** (`--timeframe`): `M1`, `M2`, `M3`, `M4`, `M5`, `M6`, `M10`,
|
|
47
|
+
`M12`, `M15`, `M20`, `M30`, `H1`, `H2`, `H3`, `H4`, `H6`, `H8`, `H12`,
|
|
48
|
+
`D1`, `W1`, `MN1`, or the raw integer.
|
|
49
|
+
- **Tick flags** (`--flags`): `ALL`, `INFO`, `TRADE`, or the raw integer.
|
|
50
|
+
|
|
51
|
+
## Commands
|
|
52
|
+
|
|
53
|
+
| Command | Required options | Optional options |
|
|
54
|
+
| ----------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `rates-from` | `--symbol`, `--timeframe`, `--date-from`, `--count` | — |
|
|
56
|
+
| `rates-from-pos` | `--symbol`, `--timeframe`, `--start-pos`, `--count` | — |
|
|
57
|
+
| `rates-range` | `--symbol`, `--timeframe`, `--date-from`, `--date-to` | — |
|
|
58
|
+
| `ticks-from` | `--symbol`, `--date-from`, `--count`, `--flags` | — |
|
|
59
|
+
| `ticks-range` | `--symbol`, `--date-from`, `--date-to`, `--flags` | — |
|
|
60
|
+
| `account-info` | — | — |
|
|
61
|
+
| `terminal-info` | — | — |
|
|
62
|
+
| `symbols` | — | `--group` (e.g., `*USD*`) |
|
|
63
|
+
| `symbol-info` | `--symbol` | — |
|
|
64
|
+
| `orders` | — | `--symbol`, `--group`, `--ticket` |
|
|
65
|
+
| `positions` | — | `--symbol`, `--group`, `--ticket` |
|
|
66
|
+
| `history-orders` | — | `--date-from`, `--date-to`, `--group`, `--symbol`, `--ticket`, `--position` |
|
|
67
|
+
| `history-deals` | — | `--date-from`, `--date-to`, `--group`, `--symbol`, `--ticket`, `--position` |
|
|
68
|
+
| `collect-history` | `--symbol` (repeatable), `--date-from`, `--date-to` | `--dataset` (repeatable; rates/ticks/history-orders/history-deals; default all), `--timeframe` (M1; recorded on rates), `--flags` (ALL), `--if-exists` (append/replace/fail; default fail), `--with-views` (SQLite3 output only) |
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Account snapshot as CSV.
|
|
74
|
+
mt5cli -o account.csv account-info
|
|
75
|
+
|
|
76
|
+
# EURUSD M1 bars (1000 rows) from a start date to Parquet.
|
|
77
|
+
mt5cli -o rates.parquet rates-from \
|
|
78
|
+
--symbol EURUSD --timeframe M1 --date-from 2024-01-01 --count 1000
|
|
79
|
+
|
|
80
|
+
# EURUSD tick stream for a date range to JSON.
|
|
81
|
+
mt5cli -o ticks.json ticks-range \
|
|
82
|
+
--symbol EURUSD --date-from 2024-01-01 --date-to 2024-01-02 --flags ALL
|
|
83
|
+
|
|
84
|
+
# USD symbols into a named table in SQLite3.
|
|
85
|
+
mt5cli -o data.db --table symbols symbols --group "*USD*"
|
|
86
|
+
|
|
87
|
+
# Historical deals filtered by symbol (using an already-logged-in MT5 terminal).
|
|
88
|
+
mt5cli -o deals.csv history-deals --symbol EURUSD --date-from 2024-01-01
|
|
89
|
+
|
|
90
|
+
# Bundle selected historical datasets into one SQLite db, appending to any
|
|
91
|
+
# existing tables, plus cash_events and positions_reconstructed views.
|
|
92
|
+
mt5cli -o history.db collect-history \
|
|
93
|
+
--symbol EURUSD --symbol GBPUSD \
|
|
94
|
+
--date-from 2024-01-01 --date-to 2024-02-01 \
|
|
95
|
+
--dataset rates --dataset history-deals \
|
|
96
|
+
--timeframe M1 --flags ALL --if-exists append --with-views
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Guidelines
|
|
100
|
+
|
|
101
|
+
- Pick the output extension to avoid passing `--format`.
|
|
102
|
+
- Use `--table` only with SQLite3 outputs; it is otherwise ignored.
|
|
103
|
+
- `--count` is required for `rates-from`, `rates-from-pos`, and `ticks-from`.
|
|
104
|
+
Prefer `rates-range` / `ticks-range` when a fixed window is known.
|
|
105
|
+
- Credentials (`--login`, `--password`, `--server`) are optional when the
|
|
106
|
+
local MT5 terminal is already logged in.
|
|
107
|
+
- Avoid passing `--password` on the command line in shared or logged
|
|
108
|
+
environments — it is visible in `ps`, shell history, and CI logs. Prefer
|
|
109
|
+
logging in through the MT5 terminal first, then omit credentials here.
|
|
110
|
+
- Reach for `--log-level DEBUG` when a command fails silently — MT5
|
|
111
|
+
connection errors surface there.
|
|
112
|
+
- If the user asks to run from source in this repo, prefix with `uv run`
|
|
113
|
+
(e.g., `uv run mt5cli -o out.csv account-info`).
|
|
@@ -35,7 +35,7 @@ jobs:
|
|
|
35
35
|
|| (github.event_name == 'workflow_dispatch' && inputs.workflow == 'lint-and-test')
|
|
36
36
|
permissions:
|
|
37
37
|
contents: read
|
|
38
|
-
uses: dceoy/gh-actions-for-devops/.github/workflows/python-package-lint-and-scan.yml@main
|
|
38
|
+
uses: dceoy/gh-actions-for-devops/.github/workflows/python-package-lint-and-scan.yml@main # zizmor: ignore[unpinned-uses]
|
|
39
39
|
with:
|
|
40
40
|
package-path: .
|
|
41
41
|
runs-on: windows-latest
|
|
@@ -59,7 +59,6 @@ jobs:
|
|
|
59
59
|
uses: dceoy/gh-actions-for-devops/.github/workflows/python-package-mkdocs-gh-deploy.yml@main # zizmor: ignore[unpinned-uses]
|
|
60
60
|
with:
|
|
61
61
|
package-path: .
|
|
62
|
-
mkdocs-theme: material
|
|
63
62
|
runs-on: ubuntu-slim
|
|
64
63
|
secrets:
|
|
65
64
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mt5cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Command-line tool for MetaTrader 5
|
|
5
5
|
Project-URL: Repository, https://github.com/dceoy/mt5cli.git
|
|
6
6
|
Author-email: dceoy <dceoy@users.noreply.github.com>
|
|
@@ -74,30 +74,45 @@ python -m mt5cli -o account.csv account-info
|
|
|
74
74
|
|
|
75
75
|
## Commands
|
|
76
76
|
|
|
77
|
-
| Command | Description
|
|
78
|
-
| ------------------ |
|
|
79
|
-
| `rates-from` | Export rates from a start date
|
|
80
|
-
| `rates-from-pos` | Export rates from a start position
|
|
81
|
-
| `rates-range` | Export rates for a date range
|
|
82
|
-
| `ticks-from` | Export ticks from a start date
|
|
83
|
-
| `ticks-range` | Export ticks for a date range
|
|
84
|
-
| `account-info` | Export account information
|
|
85
|
-
| `terminal-info` | Export terminal information
|
|
86
|
-
| `version` | Export MetaTrader 5 version information
|
|
87
|
-
| `last-error` | Export the last error information
|
|
88
|
-
| `symbols` | Export symbol list
|
|
89
|
-
| `symbol-info` | Export symbol details
|
|
90
|
-
| `symbol-info-tick` | Export the last tick for a symbol
|
|
91
|
-
| `market-book` | Export market depth (order book)
|
|
92
|
-
| `orders` | Export active orders
|
|
93
|
-
| `positions` | Export open positions
|
|
94
|
-
| `history-orders` | Export historical orders
|
|
95
|
-
| `history-deals` | Export historical deals
|
|
96
|
-
| `order-check` | Check funds sufficiency for a trade request
|
|
97
|
-
| `order-send` | Send a trade request to the trade server (`--yes` required)
|
|
77
|
+
| Command | Description |
|
|
78
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------ |
|
|
79
|
+
| `rates-from` | Export rates from a start date |
|
|
80
|
+
| `rates-from-pos` | Export rates from a start position |
|
|
81
|
+
| `rates-range` | Export rates for a date range |
|
|
82
|
+
| `ticks-from` | Export ticks from a start date |
|
|
83
|
+
| `ticks-range` | Export ticks for a date range |
|
|
84
|
+
| `account-info` | Export account information |
|
|
85
|
+
| `terminal-info` | Export terminal information |
|
|
86
|
+
| `version` | Export MetaTrader 5 version information |
|
|
87
|
+
| `last-error` | Export the last error information |
|
|
88
|
+
| `symbols` | Export symbol list |
|
|
89
|
+
| `symbol-info` | Export symbol details |
|
|
90
|
+
| `symbol-info-tick` | Export the last tick for a symbol |
|
|
91
|
+
| `market-book` | Export market depth (order book) |
|
|
92
|
+
| `orders` | Export active orders |
|
|
93
|
+
| `positions` | Export open positions |
|
|
94
|
+
| `history-orders` | Export historical orders |
|
|
95
|
+
| `history-deals` | Export historical deals |
|
|
96
|
+
| `order-check` | Check funds sufficiency for a trade request |
|
|
97
|
+
| `order-send` | Send a trade request to the trade server (`--yes` required) |
|
|
98
|
+
| `collect-history` | Bundle rates, ticks, history-orders, and history-deals for one or more symbols into a single SQLite database |
|
|
98
99
|
|
|
99
100
|
Use `order-check` to validate a request payload before running `order-send --yes`.
|
|
100
101
|
|
|
102
|
+
### `collect-history`
|
|
103
|
+
|
|
104
|
+
Collect several historical datasets per symbol into one SQLite database in a single MT5 session. Pick datasets with repeatable `--dataset` (default: all four), choose conflict behavior with `--if-exists append|replace|fail` (default: `fail`), and optionally derive `cash_events` / `positions_reconstructed` views from `history_deals` via `--with-views`.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
mt5cli -o history.db collect-history \
|
|
108
|
+
--symbol EURUSD --symbol GBPUSD \
|
|
109
|
+
--date-from 2024-01-01 --date-to 2024-02-01 \
|
|
110
|
+
--dataset rates --dataset history-deals \
|
|
111
|
+
--timeframe M1 --flags ALL --if-exists append --with-views
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
History orders and deals are fetched per symbol and concatenated, so the symbol filter is applied consistently across all datasets. The `cash_events` view is derived from symbol-filtered `history_deals`, so account-level cash events with empty or non-matching symbols may be excluded. The `rates` table records the requested `timeframe` so appended runs at different timeframes remain distinguishable. The `positions_reconstructed` view aggregates trade deals by `position_id`, excludes positions without closing deals, and uses volume-weighted open/close prices; reversal deals (`DEAL_ENTRY_INOUT`) are reported via `volume_reversal` / `reversal_count` columns and do not contribute to the weighted prices.
|
|
115
|
+
|
|
101
116
|
## Requirements
|
|
102
117
|
|
|
103
118
|
- Python 3.11+
|
|
@@ -50,30 +50,45 @@ python -m mt5cli -o account.csv account-info
|
|
|
50
50
|
|
|
51
51
|
## Commands
|
|
52
52
|
|
|
53
|
-
| Command | Description
|
|
54
|
-
| ------------------ |
|
|
55
|
-
| `rates-from` | Export rates from a start date
|
|
56
|
-
| `rates-from-pos` | Export rates from a start position
|
|
57
|
-
| `rates-range` | Export rates for a date range
|
|
58
|
-
| `ticks-from` | Export ticks from a start date
|
|
59
|
-
| `ticks-range` | Export ticks for a date range
|
|
60
|
-
| `account-info` | Export account information
|
|
61
|
-
| `terminal-info` | Export terminal information
|
|
62
|
-
| `version` | Export MetaTrader 5 version information
|
|
63
|
-
| `last-error` | Export the last error information
|
|
64
|
-
| `symbols` | Export symbol list
|
|
65
|
-
| `symbol-info` | Export symbol details
|
|
66
|
-
| `symbol-info-tick` | Export the last tick for a symbol
|
|
67
|
-
| `market-book` | Export market depth (order book)
|
|
68
|
-
| `orders` | Export active orders
|
|
69
|
-
| `positions` | Export open positions
|
|
70
|
-
| `history-orders` | Export historical orders
|
|
71
|
-
| `history-deals` | Export historical deals
|
|
72
|
-
| `order-check` | Check funds sufficiency for a trade request
|
|
73
|
-
| `order-send` | Send a trade request to the trade server (`--yes` required)
|
|
53
|
+
| Command | Description |
|
|
54
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------ |
|
|
55
|
+
| `rates-from` | Export rates from a start date |
|
|
56
|
+
| `rates-from-pos` | Export rates from a start position |
|
|
57
|
+
| `rates-range` | Export rates for a date range |
|
|
58
|
+
| `ticks-from` | Export ticks from a start date |
|
|
59
|
+
| `ticks-range` | Export ticks for a date range |
|
|
60
|
+
| `account-info` | Export account information |
|
|
61
|
+
| `terminal-info` | Export terminal information |
|
|
62
|
+
| `version` | Export MetaTrader 5 version information |
|
|
63
|
+
| `last-error` | Export the last error information |
|
|
64
|
+
| `symbols` | Export symbol list |
|
|
65
|
+
| `symbol-info` | Export symbol details |
|
|
66
|
+
| `symbol-info-tick` | Export the last tick for a symbol |
|
|
67
|
+
| `market-book` | Export market depth (order book) |
|
|
68
|
+
| `orders` | Export active orders |
|
|
69
|
+
| `positions` | Export open positions |
|
|
70
|
+
| `history-orders` | Export historical orders |
|
|
71
|
+
| `history-deals` | Export historical deals |
|
|
72
|
+
| `order-check` | Check funds sufficiency for a trade request |
|
|
73
|
+
| `order-send` | Send a trade request to the trade server (`--yes` required) |
|
|
74
|
+
| `collect-history` | Bundle rates, ticks, history-orders, and history-deals for one or more symbols into a single SQLite database |
|
|
74
75
|
|
|
75
76
|
Use `order-check` to validate a request payload before running `order-send --yes`.
|
|
76
77
|
|
|
78
|
+
### `collect-history`
|
|
79
|
+
|
|
80
|
+
Collect several historical datasets per symbol into one SQLite database in a single MT5 session. Pick datasets with repeatable `--dataset` (default: all four), choose conflict behavior with `--if-exists append|replace|fail` (default: `fail`), and optionally derive `cash_events` / `positions_reconstructed` views from `history_deals` via `--with-views`.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
mt5cli -o history.db collect-history \
|
|
84
|
+
--symbol EURUSD --symbol GBPUSD \
|
|
85
|
+
--date-from 2024-01-01 --date-to 2024-02-01 \
|
|
86
|
+
--dataset rates --dataset history-deals \
|
|
87
|
+
--timeframe M1 --flags ALL --if-exists append --with-views
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
History orders and deals are fetched per symbol and concatenated, so the symbol filter is applied consistently across all datasets. The `cash_events` view is derived from symbol-filtered `history_deals`, so account-level cash events with empty or non-matching symbols may be excluded. The `rates` table records the requested `timeframe` so appended runs at different timeframes remain distinguishable. The `positions_reconstructed` view aggregates trade deals by `position_id`, excludes positions without closing deals, and uses volume-weighted open/close prices; reversal deals (`DEAL_ENTRY_INOUT`) are reported via `volume_reversal` / `reversal_count` columns and do not contribute to the weighted prices.
|
|
91
|
+
|
|
77
92
|
## Requirements
|
|
78
93
|
|
|
79
94
|
- Python 3.11+
|
|
@@ -74,17 +74,46 @@ mt5cli --login 12345 --password mypass --server MyBroker-Demo \
|
|
|
74
74
|
|
|
75
75
|
### Trading
|
|
76
76
|
|
|
77
|
-
| Command | Description
|
|
78
|
-
| ---------------- |
|
|
79
|
-
| `orders` | Export active orders
|
|
80
|
-
| `positions` | Export open positions
|
|
81
|
-
| `history-orders` | Export historical orders
|
|
82
|
-
| `history-deals` | Export historical deals
|
|
83
|
-
| `order-check` | Check funds sufficiency for a trade request
|
|
77
|
+
| Command | Description |
|
|
78
|
+
| ---------------- | ----------------------------------------------------------- |
|
|
79
|
+
| `orders` | Export active orders |
|
|
80
|
+
| `positions` | Export open positions |
|
|
81
|
+
| `history-orders` | Export historical orders |
|
|
82
|
+
| `history-deals` | Export historical deals |
|
|
83
|
+
| `order-check` | Check funds sufficiency for a trade request |
|
|
84
84
|
| `order-send` | Send a trade request to the trade server (`--yes` required) |
|
|
85
85
|
|
|
86
86
|
Use `order-check` to validate a request payload before running `order-send --yes`.
|
|
87
87
|
|
|
88
|
+
### Bulk Collection
|
|
89
|
+
|
|
90
|
+
| Command | Description |
|
|
91
|
+
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| `collect-history` | Collect rates, ticks, history-orders, and history-deals for one or more symbols into a single SQLite database (optional cash-event/position views) |
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
mt5cli -o history.db collect-history \
|
|
96
|
+
--symbol EURUSD --symbol GBPUSD \
|
|
97
|
+
--date-from 2024-01-01 --date-to 2024-02-01 \
|
|
98
|
+
--dataset rates --dataset history-deals \
|
|
99
|
+
--timeframe M1 --flags ALL --if-exists append --with-views
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`collect-history` options:
|
|
103
|
+
|
|
104
|
+
| Option | Default | Description |
|
|
105
|
+
| -------------- | ---------- | --------------------------------------------------------------------------------------------- |
|
|
106
|
+
| `--symbol/-s` | _required_ | Symbol to collect (repeat for multiple). |
|
|
107
|
+
| `--date-from` | _required_ | Start date in ISO 8601. |
|
|
108
|
+
| `--date-to` | _required_ | End date in ISO 8601. |
|
|
109
|
+
| `--dataset` | all four | Repeatable: `rates`, `ticks`, `history-orders`, `history-deals`. |
|
|
110
|
+
| `--timeframe` | `M1` | Rates timeframe; recorded in a `timeframe` column on the `rates` table. |
|
|
111
|
+
| `--flags` | `ALL` | Tick copy flags forwarded to `copy_ticks_range`. |
|
|
112
|
+
| `--if-exists` | `fail` | `append`, `replace`, or `fail` when a target table already exists. |
|
|
113
|
+
| `--with-views` | off | Add `cash_events` and `positions_reconstructed` views (requires the `history-deals` dataset). |
|
|
114
|
+
|
|
115
|
+
History orders and deals are fetched per symbol and concatenated, so the symbol filter is applied consistently across all datasets. The `cash_events` view is derived from symbol-filtered `history_deals`, so account-level cash events with empty or non-matching symbols may be excluded. The `positions_reconstructed` view excludes positions with no closing deal, uses volume-weighted open/close prices, and reports reversal deals (`DEAL_ENTRY_INOUT`) via `volume_reversal` / `reversal_count`.
|
|
116
|
+
|
|
88
117
|
## Global Options
|
|
89
118
|
|
|
90
119
|
| Option | Description |
|