Add optional base ccy argument to beanprice contract?

44 views
Skip to first unread message

Patrick Ruckstuhl

unread,
Apr 11, 2021, 2:52:45 PM4/11/21
to bean...@googlegroups.com
Hi,

I started looking into moving my price fetchers into beanprice and
noticed something.

Most of my price sources actually allow you to specify in which base ccy
to return the result.

As far as I can tell, at the moment the Source interface

https://github.com/beancount/beanprice/blob/master/beanprice/source.py

doesn't have a way where you can request prices in a certain base ccy,
the only thing the source can do is specify in which base ccy it did
return them.

Should the source contract be extended to (optionally) allow to specify
the desired base ccy?


Regards,

Patrick


Martin Blais

unread,
Apr 11, 2021, 3:23:58 PM4/11/21
to Beancount
I don't think so.
Conversions is something you should be doing from the caller side.
Price sources should always return numbers in original quote currencies


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/beancount/dd26456f-bc40-356e-ada7-aa4729425355%40ch.tario.org.

Patrick Ruckstuhl

unread,
Apr 11, 2021, 4:03:31 PM4/11/21
to Martin Blais, Beancount
I think my cases are often cases where there is no "original" quote currency. E.g. fx rates or crypto rates. At least for me it's very useful to specify in which currency I want to get my rates.

As an alternative I can create a custom ticker format.

One related thing I'm not getting is, that both the source can specify in which base it returns the quote but there is also the first part of the base specified on the source string.

Martin Blais

unread,
Apr 11, 2021, 5:45:55 PM4/11/21
to Patrick Ruckstuhl, Martin Blais, Beancount
I view these are different financial instruments altogether
spot fx: USD/JPY != USD/GBP
Ditto for DA:  BTC/USD != BTC/EUR


Patrick Ruckstuhl

unread,
Apr 12, 2021, 1:54:34 AM4/12/21
to Martin Blais, Beancount
True, looking at it from that point it makes sense to have it part of the ticker. Thanks for the discussion.

Tomasz Zurkowski

unread,
Apr 12, 2021, 1:58:23 AM4/12/21
to Beancount
In my ledger I have USD's that I want to convert to CHF, so I need a price of USD in CHF as base price. I do it by adding following commodity:

2013-01-01 commodity USD
  price: "CHF:yahoo/USDCHF=X"

The base currency is encoded in the source specific symbol. Now, it might look weird that all tickers are listed twice here, but it is required because we need to convert from the symbols we use in our ledger, to symbols that are used by price source (which might differ).
Reply all
Reply to author
Forward
0 new messages