Beanprice custom source

112 views
Skip to first unread message

Thomas den Hollander

unread,
Apr 11, 2021, 5:51:24 AM4/11/21
to Beancount

Hello everyone,

I wanted to write custom sources for bean-price, but I'm unsure what the best way to do this is. I'm not very experienced with Python or its module system. Say I have a folder with my own sources, how do I reference these while fetching the price? Should I add the path to my PYTHONPATH? Or maybe install it as a module?

- Thomas

Martin Blais

unread,
Apr 11, 2021, 9:34:51 AM4/11/21
to Beancount
You can reference them by the name of their Python module if they're outside the library.
You can use the short name if they're in the library, here:

New ones are welcome. Minimal requirement for inclusion in the library is a unit test covering basic usage and mocked, that is, not connecting to the network.



--
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/7604ca29-5482-41c2-8757-2fe11e5a3610n%40googlegroups.com.

Thomas den Hollander

unread,
Apr 11, 2021, 11:39:18 AM4/11/21
to Beancount
Thanks! My price source is pretty specific, but I'll probably publish it at some point.

Op zondag 11 april 2021 om 15:34:51 UTC+2 schreef bl...@furius.ca:

Thomas den Hollander

unread,
Apr 11, 2021, 1:38:40 PM4/11/21
to Beancount
One more question. Many price sources are only available in USD while my main currency is EUR. How do I deal with that? Is Fava able to display the total worth by converting via USD to EUR? Should I convert these price statements myself, and if so, would it be useful to have such functionality in bean-price?

Op zondag 11 april 2021 om 17:39:18 UTC+2 schreef Thomas den Hollander:

Martin Blais

unread,
Apr 11, 2021, 2:04:36 PM4/11/21
to Beancount
Fava is a completely different question and AFAIK it should respect Beancount's notion of "operating currency", which is configurable.

For Beanprice, the sources may return their quote currency, here:


Patrick Ruckstuhl

unread,
Apr 11, 2021, 2:30:59 PM4/11/21
to bean...@googlegroups.com

What I'm using is to calculate cross rates on the flying using a plugin:


So if you have e.g. a stock price in USD and the fx rate between EUR and USD, it calculates the stock price in EUR


https://github.com/tarioch/beancounttools/blob/master/src/tariochbctools/plugins/generate_base_ccy_prices.py


Regards,

Patrick

Thomas den Hollander

unread,
Apr 12, 2021, 8:06:01 AM4/12/21
to Beancount
Computing prices on the fly is nice. However, using it with bean-price doesn't seem ideal. For example, the required USD/EUR prices are not fetched by --update if I don't have any USD myself.

Would it be a good idea to have some sort of pipe syntax for bean-price? Something like EUR:(source1/ticker1>source2/ticker2) that would first fetch the price of ticker1 and then convert the currency base using ticker2? It can just be a chain of multiplication since '^' would take care of divisions.
Op zondag 11 april 2021 om 20:30:59 UTC+2 schreef pat...@ch.tario.org:

Thomas den Hollander

unread,
Apr 12, 2021, 8:41:44 AM4/12/21
to Beancount
Actually, this can be implemented as another price source with the piped sources in place of its ticker symbol. That way, no code changes are required for bean-price itself.

Op maandag 12 april 2021 om 14:06:01 UTC+2 schreef Thomas den Hollander:
Reply all
Reply to author
Forward
0 new messages