Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 756faf747b |
@@ -1,6 +1,6 @@
|
||||
# SQLite History Module
|
||||
# History Collection (SQLite)
|
||||
|
||||
::: mt5cli.sqlite_history
|
||||
::: mt5cli.history
|
||||
|
||||
## `collect-history` schema
|
||||
|
||||
@@ -18,6 +18,10 @@ Utility module providing constants, enums, Click parameter types, and helper fun
|
||||
|
||||
Programmatic SDK for read-only MetaTrader 5 data collection. Returns pandas DataFrames and provides `collect_history` for SQLite bulk collection.
|
||||
|
||||
### [History Collection (SQLite)](history.md)
|
||||
|
||||
SQLite storage helpers for the `collect-history` command schema, incremental updates, deduplication, indexes, and optional views.
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
The package follows a simple architecture built on top of pdmt5:
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ mt5cli -o history.db collect-history \
|
||||
|
||||
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`.
|
||||
|
||||
See the [SQLite History schema diagram](api/sqlite_history.md#entity-relationship-diagram) for a sample ER layout of the resulting database.
|
||||
See the [History schema diagram](api/history.md#entity-relationship-diagram) for a sample ER layout of the resulting database.
|
||||
|
||||
## Global Options
|
||||
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ nav:
|
||||
- Overview: api/index.md
|
||||
- CLI: api/cli.md
|
||||
- SDK: api/sdk.md
|
||||
- SQLite History: api/sqlite_history.md
|
||||
- History Collection (SQLite): api/history.md
|
||||
- Utils: api/utils.md
|
||||
|
||||
markdown_extensions:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""SQLite helpers for incremental MT5 history collection."""
|
||||
"""SQLite storage helpers for the ``collect-history`` incremental data pipeline."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ from typing import TYPE_CHECKING, Self, TypeVar
|
||||
|
||||
from pdmt5 import Mt5Config, Mt5DataClient
|
||||
|
||||
from .sqlite_history import (
|
||||
from .history import (
|
||||
create_cash_events_view,
|
||||
create_history_indexes,
|
||||
create_positions_reconstructed_view,
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "mt5cli"
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
description = "Command-line tool for MetaTrader 5"
|
||||
authors = [{name = "dceoy", email = "dceoy@users.noreply.github.com"}]
|
||||
maintainers = [{name = "dceoy", email = "dceoy@users.noreply.github.com"}]
|
||||
@@ -124,7 +124,7 @@ ignore = [
|
||||
]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"mt5cli/sqlite_history.py" = ["TC003"]
|
||||
"mt5cli/history.py" = ["TC003"]
|
||||
"tests/**/*.py" = [
|
||||
"DOC201", # Missing return documentation
|
||||
"DOC501", # Raised exception missing from docstring
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Tests for mt5cli.sqlite_history module."""
|
||||
"""Tests for mt5cli.history module."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -14,7 +14,7 @@ import pytest
|
||||
if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
from mt5cli.sqlite_history import (
|
||||
from mt5cli.history import (
|
||||
DEFAULT_HISTORY_TIMEFRAMES,
|
||||
append_dataframe,
|
||||
augment_written_columns_from_sqlite,
|
||||
@@ -1024,7 +1024,7 @@ class TestIncrementalIntegration:
|
||||
sqlite3.connect(tmp_path / "no-keys.db") as conn,
|
||||
caplog.at_level(
|
||||
logging.WARNING,
|
||||
logger="mt5cli.sqlite_history",
|
||||
logger="mt5cli.history",
|
||||
),
|
||||
):
|
||||
deduplicate_history_tables(conn, {Dataset.ticks: {"time"}}, {Dataset.ticks})
|
||||
@@ -1059,7 +1059,7 @@ class TestIncrementalIntegration:
|
||||
client = MagicMock()
|
||||
client.copy_rates_range_as_df.return_value = pd.DataFrame()
|
||||
with (
|
||||
caplog.at_level(logging.WARNING, logger="mt5cli.sqlite_history"),
|
||||
caplog.at_level(logging.WARNING, logger="mt5cli.history"),
|
||||
sqlite3.connect(tmp_path / "views-warning.db") as conn,
|
||||
):
|
||||
write_incremental_datasets(
|
||||
+1
-1
@@ -16,6 +16,7 @@ if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
from mt5cli import sdk
|
||||
from mt5cli.history import DEFAULT_HISTORY_TIMEFRAMES
|
||||
from mt5cli.sdk import (
|
||||
Mt5CliClient,
|
||||
account_info,
|
||||
@@ -40,7 +41,6 @@ from mt5cli.sdk import (
|
||||
update_history_with_config,
|
||||
version,
|
||||
)
|
||||
from mt5cli.sqlite_history import DEFAULT_HISTORY_TIMEFRAMES
|
||||
from mt5cli.utils import Dataset
|
||||
|
||||
_DEALS_FIXTURE: dict[str, list[object]] = {
|
||||
|
||||
Reference in New Issue
Block a user