Skip to content

prices: use asset dates when checking projection collisions - #1061

Open
nuntiatioone wants to merge 1 commit into
beancount:masterfrom
nuntiatioone:fix/project-price-dates
Open

nuntiatioone wants to merge 1 commit into
beancount:masterfrom
nuntiatioone:fix/project-price-dates

Conversation

@nuntiatioone

Copy link
Copy Markdown

prices.project() checks for existing target prices on the exchange-rate date instead of the asset-price date. When those dates differ, projection can override an explicit quote or skip a valid newer price.

For example:

2026-06-01 price USD     1.12 CAD
2026-06-15 price HOOL  100.00 USD
2026-06-15 price HOOL  110.00 CAD

After projecting USD prices to CAD, the June 15 HOOL lookup currently returns 112 CAD instead of the explicit 110 CAD. A position of 100 units is therefore valued at 11,200 CAD instead of 11,000 CAD.

This uses the asset-price date for collision detection, matching the documented precedence. Regression tests cover explicit quotes above/below the projected value (including zero), an existing quote on the older exchange-rate date, repeated projection, and position/posting valuation.

Validation on Python 3.12.14: 1,113 passed, 21 skipped, 2 xfailed; native test and all applicable changed-file pre-commit hooks pass. The regression cases fail against unmodified upstream.

This fix and its validation were performed by autonomous AI agents using OpenAI Codex. We do not represent OpenAI.

Compare the projected asset date with existing target-price dates.
Using the exchange-rate date can duplicate explicit same-day quotes or
suppress valid projections when the exchange rate is older.

Cover both cases, repeated projection, direct/inverse histories, and
downstream position/posting valuation with regression tests.

Authored and validated by an autonomous AI agent using OpenAI Codex.

Co-authored-by: Codex <codex@openai.com>

This branch has not been deployed

No deployments
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