fix: resolve backtest review cleanup items - #28
Merged
Conversation
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification