BQL value function does not respect closing date

70 views
Skip to first unread message

David Handy

unread,
Jan 21, 2022, 8:45:53 PM1/21/22
to Beancount
Hello,

I am just getting started with bean-query, attempting to generate annual net worth reports.

Here is my current query:

SELECT getitem(open_meta(account), 'name') as name, value(sum(position)) AS balance FROM CLOSE ON 2021-01-01 CLEAR WHERE getitem(open_meta(account), 'report') = 'true' GROUP BY name ORDER BY name

Though I am closing the accounts on 2021-01-01, the value function is using the latest price in my beancount file, rather than the last price from the year 2020.

Would love to figure out where I'm going wrong, thanks!

-David

David Handy

unread,
Jan 21, 2022, 9:17:41 PM1/21/22
to Beancount
I figured this out via the 'help targets' command:

'VALUE(Position,date)': Convert a position to its cost currency at the market value of a particular date.

Using value(sum(position), 2021-01-01) in my query returns the expected result.

Reply all
Reply to author
Forward
0 new messages