Skip to content

Avoid zero-total normalization in greedy discrete allocation - #3

Merged
Geochelone666 merged 1 commit into
mainfrom
maintenance-zero-initial-allocation
Oct 22, 2026
Merged

Geochelone666 merged 1 commit into
mainfrom
maintenance-zero-initial-allocation

Conversation

@Geochelone666

@Geochelone666 Geochelone666 commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

When every first-round share count is zero, greedy_portfolio divides its zero current-value vector by zero before choosing the next affordable asset. This emits an invalid-value warning and raises FloatingPointError for callers that enable NumPy floating-point errors, despite valid prices and budget.

Keep the current allocation weights at zero until some capital is invested; normalize only a positive invested total. Add regressions for a small budget that can buy one lower-priced asset and a budget that cannot buy any asset, with invalid/divide errors enabled. Both cases fail before the fix.

Validation: all 21 discrete-allocation tests pass. Full local suite from the repository root: 306 passed, 22 skipped (41 existing solver/statistics warnings). CI code quality and focused Python 3.11/3.12 allocation jobs pass; the broader platform/Python/notebook matrix is running.

@Geochelone666
Geochelone666 merged commit 5afe88e into main Oct 22, 2026
40 checks passed
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