bean-price usage question

574 views
Skip to first unread message

Jacques Gagnon

unread,
Dec 14, 2015, 9:43:27 AM12/14/15
to Beancount
I'm trying to use bean-price so that I could run a query like 'BALANCES AT COST' to have my stock position in USD rather than the amount of units.

It work fine when I'm using a journal generated from bean-example but with my own file it's not, and I can't see why. :s

Any idea Martin?

Here my test file:
$ cat test.bean 
option "title" "Example Beancount file"
option "operating_currency" "USD"

2011-05-31 commodity RGAGX
  export: "MUTF:RGAGX"
  price: "USD:google/MUTF:RGAGX"

2015-09-30 open Equity:Opening-Balances
2015-09-30 open Assets:RGAGX  RGAGX
2015-09-30 pad Assets:RGAGX Equity:Opening-Balances
2015-10-01 balance Assets:RGAGX  1500.0001 RGAGX

If I run bean-price on the file nothing happen:
$ bean-price -v test.bean 
INFO    : Using price cache at "/tmp/bean-price.cache" (with indefinite expiration)
INFO    : Processing at date: 2015-12-14
INFO    : Loading "test.bean"

Running the query manually work:
$ bean-price -e USD:google/MUTF:RGAGX 
2015-12-11 price MUTF:RGAGX                           44.4 USD

So I add it manualy:
$ bean-price -e USD:google/MUTF:RGAGX >> test.bean 

Here I get an error because bean-price output MUTF:RGAGX
$ bean-query test.bean 'BALANCES AT COST'
test.bean:12:      ValueError: Invalid account name: MUTF:RGAGX

So at this point I just rename it to RGAGX but my BALANCES report still show up unit of RGAGX
$ bean-query test.bean 'BALANCES AT COST'
        account         sum_cost_position
----------------------- -----------------
Assets:RGAGX             1500.0001 RGAGX
Equity:Opening-Balances -1500.0001 RGAGX

Any idea what I'm doing wrong?

Jacques Gagnon

unread,
Dec 14, 2015, 1:48:00 PM12/14/15
to Beancount
To answer my self, I guess its because since it's from my opening-balances their is not know value of the original cost.

Beside COST and UNITS does we have an aggregation function for displaying the current value base on the lasted price?

Martin Blais

unread,
Dec 14, 2015, 11:06:53 PM12/14/15
to Beancount
Hi Jacques,
The problem here is that the units of RGAGX aren't held "at cost", that is, you did not attach a cost basis to them.
This should work, for instance:


;; -*- mode: beancount -*-                           

option "title" "Example Beancount file"
option "operating_currency" "USD"

2011-05-31 commodity RGAGX
  export: "MUTF:RGAGX"
  price: "USD:google/MUTF:RGAGX"

2015-09-30 open Equity:Opening-Balances
2015-09-30 open Assets:RGAGX  RGAGX

2015-09-30 *
  Assets:RGAGX    250.0000 RGAGX {39.24 USD}
  Assets:RGAGX    250.0000 RGAGX {41.23 USD}
  Assets:RGAGX   1000.0001 RGAGX {43.30 USD}
  Equity:Opening-Balances

2015-10-01 balance Assets:RGAGX  1500.0001 RGAGX



One design issue is that Pad directives don't work with units held at cost... there's no way to obtain the original cost basis. I don't have a solution for this yet. One idea would be to extend the balance syntax to allow one to specify the total cost basis of a position and for the Pad directive to fill in with an entry that includes that cost basis, but that's also not accurate either, because there may be more than one lot (as in the example above, three lots). 

So you have to enter the cost basis in your transactions.

By default, bean-price will consider only the currencies held at cost. Use -vv to view more detail of what it does. If you want to extend the list, you can use the -i / --inactive option to have it insert currencies seen but not on the books, e.g.


bean-price -vv /home/blais/p/beancount-data/gagnon/test.bean --inactive
INFO    : Using price cache at "/tmp/bean-price.cache" (with indefinite expiration$
INFO    : Processing at date: 2015-12-14
INFO    : Loading "/home/blais/p/beancount-data/gagnon/test.bean"
DEBUG   : -------- Currencies in primary list:
DEBUG   :                         RGAGX /USD
DEBUG   : -------- Currencies to fetch:
DEBUG   :                         RGAGX /USD
2015-12-14 price RGAGX                               44.54 USD


I hope this helps,



--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/2038b9c4-205b-4200-a23c-5d090322c164%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages