Skip to content

Parity hardening + coverage hardening - #2

Merged
stefan-jansen merged 24 commits into
mainfrom
feature/parity-hardening-coverage
Feb 27, 2026
Merged

Parity hardening + coverage hardening#2
stefan-jansen merged 24 commits into
mainfrom
feature/parity-hardening-coverage

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

Includes parity config wiring, contract tests, and result.py error-path coverage improvements.

stefan-jansen and others added 22 commits February 26, 2026 17:11
When initial_cash is passed as int (e.g., 100000), the equity curve
starts with int then transitions to float values. Polars strict mode
rejects this mixed-type list. Ensure all values are float.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- to_tearsheet() was using to_returns_series() (bar-level), which inflates
  Sharpe for intraday data. Now uses to_daily_returns() for correct metrics.
- Added calendar parameter for session alignment (crypto, CME futures).
- Pass equity_curve to generate_backtest_tearsheet() so portfolio-level
  charts can render.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Delete analysis.py shim module (414 lines)
- Remove SizingMethod enum, BacktestEngine/TrailHwmSource aliases
- Remove 6 deprecated property aliases (Trade.asset/.commission/.mfe/.mae, Position.avg_entry_price)
- Remove dict-like access on BacktestResult (__getitem__, __contains__, get)
- Remove deprecated equity metrics (sharpe/sortino/calmar methods)
- Simplify fill_executor exit reason parsing
- Update all tests for new API
Copilot AI review requested due to automatic review settings February 27, 2026 18:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR focuses on parity hardening (cross-engine validation infrastructure) and coverage hardening (error path testing). The changes significantly improve the codebase's architecture and testability without introducing breaking changes to the public API.

Changes:

  • Validation Import Bridge: Created _validation_imports.py module to provide legacy imports for validation scripts without widening public API
  • Profile System: Moved framework presets from inline code to centralized profiles.py with strict validation
  • Contract Tests: Added cross-engine parity tests and property-based tests for accounting/ordering invariants
  • Result.py Coverage: Added error-path tests for config export failures, import errors, and edge cases
  • Broker Decomposition: Split broker into specialized engines (FillEngine, ExecutionEngine, RiskEngine, OrderBook, PortfolioLedger)
  • Config Hardening: Added strict validation with allowlist-based section/key checking

Reviewed changes

Copilot reviewed 141 out of 145 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/ml4t/backtest/_validation_imports.py New validation-only import bridge
src/ml4t/backtest/profiles.py Centralized framework behavior profiles
src/ml4t/backtest/config.py Strict config validation, enum migrations
src/ml4t/backtest/core/*.py Broker decomposition into specialized engines
tests/contracts/*.py New cross-engine parity and property tests
tests/test_result.py Error-path coverage improvements
validation/run_all_correctness.py ML4T_PROFILE environment variable support
60+ validation scripts Updated to use _validation_imports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stefan-jansen
stefan-jansen merged commit fec1774 into main Feb 27, 2026
7 checks passed
@stefan-jansen
stefan-jansen deleted the feature/parity-hardening-coverage branch February 27, 2026 19:11
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.

2 participants