Skip to content

fix: resolve backtest review cleanup items - #28

Merged
stefan-jansen merged 1 commit into
mainfrom
fix/review-cleanups-2026-07
Jul 11, 2026
Merged

fix: resolve backtest review cleanup items#28
stefan-jansen merged 1 commit into
mainfrom
fix/review-cleanups-2026-07

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

Summary

  • apply contract multipliers to percentage margin validation and buying power checks
  • classify integer-share orders after rounding across execution paths
  • validate and safely serialize percentage margin schedules
  • clarify the legacy account value alias

Verification

  • uv run ruff check src tests
  • uv run ty check
  • uv run pytest tests/ -q
  • pre-commit run --all-files

Copilot AI review requested due to automatic review settings July 11, 2026 17:37

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 addresses several backtest “review cleanup” correctness items across margin accounting, order execution, and configuration serialization, improving parity and safety for futures/margin workflows.

Changes:

  • Apply contract multipliers to percentage-based margin validation and buying power calculations (including prechecks and gatekeeper validation paths).
  • Ensure integer-share rounding occurs before exit/entry classification across execution paths (notably EXIT_FIRST and sequential processing).
  • Harden config validation and YAML serialization for margin percentage schedules (including safe YAML dumping and new tests).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_config_wiring.py Adds regression tests for integer-share rounding classification and margin_pct_schedule validation/YAML roundtrip.
tests/accounting/test_margin_account_policy.py Adds futures multiplier coverage for percentage margin requirements and buying power.
src/ml4t/backtest/core/order_book.py Threads contract multipliers into NEXT_BAR submission precheck policy calls.
src/ml4t/backtest/core/execution_engine.py Moves integer-share rounding earlier to ensure correct exit/entry classification and consistent rejection behavior.
src/ml4t/backtest/config.py Adds margin schedule coercion/validation helpers and switches YAML writing to safe_dump.
src/ml4t/backtest/broker.py Passes multiplier resolver into gatekeeper and clarifies get_account_value() as an equity() alias.
src/ml4t/backtest/accounting/policy.py Applies multipliers to percentage margin, buying power, and cash/margin checks; validates margin_pct_schedule on policy construction.
src/ml4t/backtest/accounting/gatekeeper.py Adds multiplier plumbing into policy validation calls via a resolver callback.

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

Comment thread src/ml4t/backtest/config.py
Comment thread src/ml4t/backtest/config.py
Comment thread src/ml4t/backtest/config.py
@stefan-jansen
stefan-jansen merged commit 491e707 into main Jul 11, 2026
8 checks passed
@stefan-jansen
stefan-jansen deleted the fix/review-cleanups-2026-07 branch July 11, 2026 17:43
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