Skip to content

fix: handle margin schedule float overflow#32

Merged
stefan-jansen merged 1 commit into
mainfrom
fix/margin-schedule-overflow
Jul 11, 2026
Merged

fix: handle margin schedule float overflow#32
stefan-jansen merged 1 commit into
mainfrom
fix/margin-schedule-overflow

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

Summary

  • catch OverflowError while coercing, serializing, and validating margin percentage schedules
  • keep invalid overflow-triggering values YAML-safe for diagnostic export
  • add regression coverage for overflow during float(...) conversion

Verification

  • uv run pytest tests/test_config_wiring.py::TestImmediateFill::test_margin_pct_schedule_float_overflow_is_reported tests/test_config_wiring.py::TestImmediateFill::test_invalid_margin_pct_schedule_export_does_not_raise -q
  • pre-commit run --files src/ml4t/backtest/config.py tests/test_config_wiring.py

Copilot AI review requested due to automatic review settings July 11, 2026 18:07

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 hardens BacktestConfig margin percentage schedule handling against OverflowError during float(...) coercion/validation/serialization, ensuring invalid values can still be exported safely for diagnostics.

Changes:

  • Catch OverflowError while coercing and validating margin_pct_schedule values.
  • Adjust margin schedule serialization to keep invalid values YAML-safe during to_dict() / to_yaml().
  • Add regression tests covering overflow during float(...) conversion and YAML export safety.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/ml4t/backtest/config.py Adds OverflowError handling for margin schedule coercion/validation and introduces helpers for YAML-safe serialization of invalid margin schedule values.
tests/test_config_wiring.py Adds regression coverage ensuring overflow in __float__ is reported via validation and does not break YAML export.

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

Comment thread src/ml4t/backtest/config.py
@stefan-jansen stefan-jansen merged commit ceb28f8 into main Jul 11, 2026
8 checks passed
@stefan-jansen stefan-jansen deleted the fix/margin-schedule-overflow branch July 11, 2026 18:12
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