holdings: value positions at the time-filter end date - #2350
Open
ryanduguid wants to merge 1 commit into
Open
Conversation
Beanquery value() and getprice() used the latest price when undated. Holdings queries run on entries_with_all_prices, so a time filter still valued lots at later prices. Pin both functions to FilteredLedger.end_date, the same date account reports already use. Fixes beancount#2336
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2336
Holdings BQL called
value()andgetprice()without a date. Those queries run onentries_with_all_prices, so beanquery used later prices from outside the time filter. Account reports already value atFilteredLedger.end_date(“The date to use for prices.”).This moves the holdings queries to Python and pins both functions to that date. The frontend loads the report from a new
/api/holdingsendpoint so the Query link shows the dated BQL.On a ledger with
10 STOCKbought in June, priced12at month-end and20in September,time=2020-06now reports120(not200). That matches the example-file case in #2336 (5170.89 USDat 2017-08-31 vs5217.47 USDfrom a later price).Verification:
I reviewed, understand, and take responsibility for this change.