Skip to content

feat(cli): iaf index + SqliteBacktestIndex — epic #540 phase 2#542

Merged
MDUYN merged 1 commit into
feature/index-rowfrom
feature/iaf-index-cli
May 11, 2026
Merged

feat(cli): iaf index + SqliteBacktestIndex — epic #540 phase 2#542
MDUYN merged 1 commit into
feature/index-rowfrom
feature/iaf-index-cli

Conversation

@MDUYN
Copy link
Copy Markdown
Collaborator

@MDUYN MDUYN commented May 10, 2026

Stacked on #541 (phase 1). Phase 2 of epic #540 — SQLite Tier-1 index.

What

  • New SqliteBacktestIndex service (investing_algorithm_framework.services.backtest_index) — single-file SQLite database with one row per bundle. Every scalar field of BacktestSummaryMetrics is promoted to its own summary_<name> SQL column, so analysts can filter ad-hoc without opening any bundle:

    SELECT bundle_path FROM backtest_index
    WHERE summary_sharpe_ratio > 1.0 AND tag = 'live-candidate';
  • New iaf index <bundle-dir> CLI: walks the folder, opens each .iafbt with summary_only=True (no Parquet decode), derives a BacktestIndexRow, upserts. Flags: --output, --absolute-paths, --no-progress.

  • Schema details:

    • WAL journal mode for safe concurrent reads.
    • Forward-only additive migration via PRAGMA user_version — older index files get missing columns added in place.
    • parameters / strategy_ids / extras round-trip as JSON text columns; non-canonical summary fields land in summary_extras_json (forward-compat).
    • SQLite stores NaN as NULL (verified) — round-trip tests treat NaN/None as equivalent.

Tests

12 new tests:

  • 8 SqliteBacktestIndex unit tests (lifecycle, upsert PK enforcement, round-trip, replace-on-duplicate, bulk upsert, parameterised query, build-from-real-bundle).
  • 4 CLI integration tests via click.testing.CliRunner (relative vs absolute paths, custom output, full Click invocation).

Full repo suite: 1698 passed, 42 skipped, 47 subtests passed. Lint clean.

Stacking

Base is feature/index-row (#541) which is itself stacked on feature/bundle-format-v2 (#537). Once #537 + #541 merge, this PR's base auto-walks down to dev.

Tracks epic #540 — phase 2 of 3. Phase 3 (BacktestStore + LocalTieredStore) is the remaining work.

Tier-1 SQLite index over a folder of .iafbt bundles, building on the
phase-1 BacktestIndexRow contract.

* services/backtest_index/sqlite_index.py: SqliteBacktestIndex with
  create / open / upsert / upsert_many / iter_rows / query. Every
  scalar field of BacktestSummaryMetrics is promoted to its own
  summary_<name> SQL column so analysts can filter without opening
  any bundle (e.g. WHERE summary_sharpe_ratio > 1.0). parameters /
  strategy_ids / extras round-trip as JSON text. WAL mode for safe
  concurrent reads. Forward-only additive schema migration via
  PRAGMA user_version.
* cli/index_command.py + new 'iaf index <bundle-dir>' click command:
  walks the directory, opens each bundle with summary_only=True (no
  Parquet metric-blob decode), derives BacktestIndexRow, upserts.
  --output, --absolute-paths and --no-progress flags.
* docs/design/tiered-backtest-storage.md updated with phase-2 status.

Tests: 12 new (8 SqliteBacktestIndex unit tests + 4 CLI integration
tests via click.testing.CliRunner). Full repo suite green
(1698 passed, 42 skipped). Lint clean.
@MDUYN MDUYN force-pushed the feature/iaf-index-cli branch from ae91338 to c4d30d4 Compare May 10, 2026 20:32
@MDUYN MDUYN merged commit 84ccf1f into feature/index-row May 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant