Skip to content

fix: normalize inverse-vol weights in float64 - #184

Merged
Pigbibi merged 1 commit into
mainfrom
fix/inverse-vol-float64-normalization
Sep 13, 2026
Merged

Pigbibi merged 1 commit into
mainfrom
fix/inverse-vol-float64-normalization

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Problem

Downcast research inputs can leave vol20 as float32. Inverse-vol normalization then rounds a fully invested target vector above the strict sum <= 1 + 1e-12 guard (for example, 1.0000001192092896), causing the producer export to fail closed.

Change

Convert vol20 to float64 at the inverse-vol weight calculation boundary before normalization. Existing finite, non-negative, no-leverage validation and missing-volatility filtering remain unchanged.

Validation

  • Old implementation: characterization test reproduced the strict guard failure through clean_numeric_frame -> select_portfolio -> run_single_backtest.
  • python -m pytest -q tests/test_backtest_accounting.py: 29 passed, 20 subtests passed.
  • ruff check src/portfolio.py tests/test_backtest_accounting.py: passed.
  • git diff --check: passed.

The real producer recovery run 34753427333 remains failed and is not represented as recovered by this local synthetic regression.

Co-Authored-By: Codex <noreply@openai.com>
@Pigbibi
Pigbibi merged commit 923105d into main Sep 13, 2026
1 check passed
@Pigbibi
Pigbibi deleted the fix/inverse-vol-float64-normalization branch September 13, 2026 11:26
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.

1 participant