From 756faf747b2652491bdd25c465c995021af43f10 Mon Sep 17 00:00:00 2001 From: Daichi Narushima <1938249+dceoy@users.noreply.github.com> Date: Tue, 9 Jun 2026 02:40:25 +0900 Subject: [PATCH] Rename sqlite_history module to history (#17) * Rename sqlite_history module to history. Drop the sqlite-specific prefix now that history collection is the primary module name across SDK, tests, and docs. Co-authored-by: Cursor * Address PR review feedback for history module rename. Add a sqlite_history compatibility shim, clarify docs naming, and align the module docstring with the collect-history SQLite scope. Co-authored-by: Cursor * Remove sqlite_history compatibility shim. The rename to mt5cli.history is intentionally breaking; downstream code should update imports rather than rely on a deprecated re-export path. Co-authored-by: Cursor --------- Co-authored-by: Cursor --- docs/api/{sqlite_history.md => history.md} | 4 ++-- docs/api/index.md | 4 ++++ docs/index.md | 2 +- mkdocs.yml | 2 +- mt5cli/{sqlite_history.py => history.py} | 2 +- mt5cli/sdk.py | 2 +- pyproject.toml | 4 ++-- tests/{test_sqlite_history.py => test_history.py} | 8 ++++---- tests/test_sdk.py | 2 +- uv.lock | 2 +- 10 files changed, 18 insertions(+), 14 deletions(-) rename docs/api/{sqlite_history.md => history.md} (98%) rename mt5cli/{sqlite_history.py => history.py} (99%) rename tests/{test_sqlite_history.py => test_history.py} (99%) diff --git a/docs/api/sqlite_history.md b/docs/api/history.md similarity index 98% rename from docs/api/sqlite_history.md rename to docs/api/history.md index 628c73c..f47a96a 100644 --- a/docs/api/sqlite_history.md +++ b/docs/api/history.md @@ -1,6 +1,6 @@ -# SQLite History Module +# History Collection (SQLite) -::: mt5cli.sqlite_history +::: mt5cli.history ## `collect-history` schema diff --git a/docs/api/index.md b/docs/api/index.md index 01ecaaa..86b17df 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -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: diff --git a/docs/index.md b/docs/index.md index 955e449..2c4548f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 diff --git a/mkdocs.yml b/mkdocs.yml index b4cfc37..e0f3c1e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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: diff --git a/mt5cli/sqlite_history.py b/mt5cli/history.py similarity index 99% rename from mt5cli/sqlite_history.py rename to mt5cli/history.py index 9d9f2fd..6edba85 100644 --- a/mt5cli/sqlite_history.py +++ b/mt5cli/history.py @@ -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 diff --git a/mt5cli/sdk.py b/mt5cli/sdk.py index 93d3442..6e82903 100644 --- a/mt5cli/sdk.py +++ b/mt5cli/sdk.py @@ -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, diff --git a/pyproject.toml b/pyproject.toml index aded71a..0ff659d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/tests/test_sqlite_history.py b/tests/test_history.py similarity index 99% rename from tests/test_sqlite_history.py rename to tests/test_history.py index 7771dd1..f631f17 100644 --- a/tests/test_sqlite_history.py +++ b/tests/test_history.py @@ -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( diff --git a/tests/test_sdk.py b/tests/test_sdk.py index 4d68c78..98e5237 100644 --- a/tests/test_sdk.py +++ b/tests/test_sdk.py @@ -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]] = { diff --git a/uv.lock b/uv.lock index c13da59..ce1d024 100644 --- a/uv.lock +++ b/uv.lock @@ -487,7 +487,7 @@ wheels = [ [[package]] name = "mt5cli" -version = "0.4.1" +version = "0.4.2" source = { editable = "." } dependencies = [ { name = "click" },