Skip to content

fix: preserve integer affordability boundary#37

Merged
stefan-jansen merged 1 commit into
mainfrom
fix/integer-affordability-boundary
Jul 11, 2026
Merged

fix: preserve integer affordability boundary#37
stefan-jansen merged 1 commit into
mainfrom
fix/integer-affordability-boundary

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

Summary

  • use integer-domain bisection for integer partial fills so exact affordability boundaries are not rounded down by float truncation
  • add a regression test for an exact cash boundary

Verification

  • uv run pytest tests/test_config_wiring.py::TestPartialFills -q
  • pre-commit run --all-files
  • uv run ty check
  • uv run pytest tests/ -q
  • uv run mkdocs build --strict

Addresses Copilot thread PRRT_kwDOQWVsd86QIx3N from PR #36.

Copilot AI review requested due to automatic review settings July 11, 2026 19:44

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 improves the backtesting engine’s partial-fill sizing for ShareType.INTEGER by switching affordability sizing from float-domain bisection to integer-domain bisection, preventing boundary underfills caused by float truncation. It also adds a regression test to lock in the exact-cash boundary behavior.

Changes:

  • Implement integer-domain bisection in FillEngine.get_max_affordable_quantity() when share_type == INTEGER.
  • Add a regression test asserting an exact affordability boundary fill results in zero remaining cash.

Reviewed changes

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

File Description
tests/test_config_wiring.py Adds regression coverage for exact cash boundary behavior with integer partial fills.
src/ml4t/backtest/core/fill_engine.py Uses integer-domain bisection for integer-share affordability sizing to avoid float truncation underfills.

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

@stefan-jansen stefan-jansen merged commit 459abd8 into main Jul 11, 2026
8 checks passed
@stefan-jansen stefan-jansen deleted the fix/integer-affordability-boundary branch July 11, 2026 19:49
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