I can't figure out how to write a query that prints the aggregate balance of an account subtree as of a given date, converted to USD using the price as of that date. Example data:
$ cat >test.bean <<EOF
plugin "beancount.plugins.auto_accounts"
2020-01-01 * "Open"
Assets:Bank:AAA 100 AAA
Assets:Bank:BBB 100 BBB
Income:Work
2021-01-01 price AAA 1 USD
2021-01-01 price BBB 10 USD
2021-01-02 price AAA 2 USD
2021-01-02 price BBB 20 USD
2021-01-03 price AAA 3 USD
2021-01-03 price BBB 30 USD
EOF
$ bean-query test.bean 'SELECT convert(units(sum(position)), "USD") AS value WHERE account ~ "Assets:Bank"'
I'd like to be able to specify a date and get the balance at the end of that date, e.g. 2021-01-02 => 2200 USD. I tried using "FROM DATE = 2021-01-02" or "FROM DATE <= 2021-01-02" but it doesn't affect the result.