Hi,
I was hoping someone can help out with some queries I'm trying to write. I'm trying to get the market value in certain currency of all positions in some account. Closest I was able to get was from example page:
http://aumayr.github.io/beancount-sql-queries/SELECT account, units(sum(position)) AS quantity, cost(sum(position)) AS Book , convert(units(sum(position)), "CAD") AS Market FROM date > 2018-01-01 AND date < 2018-01-31 WHERE account ~ "Assets:Margin" GROUP BY account ORDER BY account
Which produces something like below where A is some stock.
| account | quantity | book | market |
| Assets:Margin:Cash | 1 CAD | 1 CAD | 1 CAD |
| Assets:Margin:A | 100 A | 100 CAD | 105 CAD |
For withdrawal/deposit query I tried this as a starting point without aggregation:
SELECT account, position FROM date > 2018-01-01 AND date < 2018-01-31 WHERE account ~ "Assets:Margin:Cash" AND position > 0
However received a stack dump (beancount 2.2.1):
Traceback (most recent call last):
File "/usr/lib/python3.7/cmd.py", line 214, in onecmd
func = getattr(self, 'do_' + cmd)
AttributeError: 'BQLShell' object has no attribute 'do_SELECT'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/beancount/query/shell.py", line 271, in run_parser
self.dispatch(statement)
File "/usr/lib/python3.7/site-packages/beancount/query/shell.py", line 251, in dispatch
return method(statement)
File "/usr/lib/python3.7/site-packages/beancount/query/shell.py", line 419, in on_Select
self.options_map)
File "/usr/lib/python3.7/site-packages/beancount/query/query_execute.py", line 275, in execute_query
if c_where is None or c_where(context):
File "/usr/lib/python3.7/site-packages/beancount/query/query_compile.py", line 121, in __call__
return self.operator(self.left(context), self.right(context))
File "/usr/lib/python3.7/site-packages/beancount/query/query_compile.py", line 121, in __call__
return self.operator(self.left(context), self.right(context))
TypeError: '>' not supported between instances of 'Position' and 'int'
Thank you.