Questions about price sources

114 views
Skip to first unread message

Patrick Ruckstuhl

unread,
Nov 27, 2018, 5:43:07 PM11/27/18
to bean...@googlegroups.com
Hi,

I'm starting to look into using the bean-price infrastructure and have a couple points/questions.

1) I specify the price ccy twice, on the one hand in the lookup expression and on the other hand the Source needs to also fill this in when creating the SourcePrice. As far as I can tell only the one from the lookup is used, which makes sense for me as often the source will not know the price ccy. Should this get dropped from SourcePrice?

2) I would like to convert all my prices into a base ccy. Is there any infrastructure around for something like this? I'm not talking about transitive prices, all I would need is to be able to convert a price into my base ccy based on an other conversion. What I'm thinking is something like
* fetch price from Source in USD
* using existing price data convert USD price into CHF

If the Source would get the existing prices I could do it in there but that's not the case and I think somewhere outside would make more sense as it should be independent of the Source. Did anyone tackle such a problem? Am I going at it the right way?

3) I'm planing to fetch prices on a daily basis and write them out as price directives so that if a price source disappears I still have all the previously fetched prices, does that make sense? Any easy way to do this with bean-price? Especially with updated intraday prices where I can't simply append the output of bean-price

Thanks for this great tool,
Patrick

Justus Pendleton

unread,
Nov 28, 2018, 10:54:21 PM11/28/18
to Beancount
On Wednesday, November 28, 2018 at 5:43:07 AM UTC+7, Patrick Ruckstuhl wrote: 
3) I'm planing to fetch prices on a daily basis and write them out as price directives so that if a price source disappears I still have all the previously fetched prices, does that make sense? Any easy way to do this with bean-price? Especially with updated intraday prices where I can't simply append the output of bean-price 
Yes, it is easy. Simply append the output of bean-price. Don't run bean-price when markets are open :). Problem solved: no intraday prices used. I use the power of computers to run bean-price at 3am.

Anyway, there's nothing wrong with just using intraday prices, too. Intraday prices aren't "wrong" and closing prices aren't "right". The closing price is just the intraday price at 4:30.

1) I specify the price ccy twice, on the one hand in the lookup expression and on the other hand the Source needs to also fill this in when creating the SourcePrice. As far as I can tell only the one from the lookup is used, which makes sense for me as often the source will not know the price ccy. Should this get dropped from SourcePrice?

Dunno. Since the currency is required ("Supported format is CCY:module/SYMBOL") I see what you're saying. I'm not sure if there's some other entry point to SourcePrice or not.
 
2) I would like to convert all my prices into a base ccy. Is there any infrastructure around for something like this? I'm not talking about transitive prices, all I would need is to be able to convert a price into my base ccy based on an other conversion. What I'm thinking is something like
* fetch price from Source in USD
* using existing price data convert USD price into CHF

I'm not sure I understand what you're trying to do. Where do you want to see this CHF? In bean-web or...? Don't you just set your operating_currency to CHF? Anyway, it *does* sound like you're talking about transitive prices. How is this different from transitive prices?

Patrick Ruckstuhl

unread,
Nov 29, 2018, 6:49:30 AM11/29/18
to Beancount


On November 29, 2018 4:54:21 AM GMT+01:00, Justus Pendleton <just...@gmail.com> wrote:
>On Wednesday, November 28, 2018 at 5:43:07 AM UTC+7, Patrick Ruckstuhl
>wrote:
>
>> 3) I'm planing to fetch prices on a daily basis and write them out as
>
>> price directives so that if a price source disappears I still have
>all the
>> previously fetched prices, does that make sense? Any easy way to do
>this
>> with bean-price? Especially with updated intraday prices where I
>can't
>> simply append the output of bean-price
>>
>Yes, it is easy. Simply append the output of bean-price. Don't run
>bean-price when markets are open :). Problem solved: no intraday prices
>
>used. I use the power of computers to run bean-price at 3am.

Not really I'm accessing different markets which have different times and some don't have a price every day, so the price date might be a previous day.
I'm looking at normalizing my "stored" prices instead of converting transitive afterwards which should be simpler.

Right now I'm creating my price db from an external system and just create a file with price statements and I'm now looking to get rid off that system and reuse as much existing functionality as possible.

Justus Pendleton

unread,
Nov 29, 2018, 9:06:51 AM11/29/18
to Beancount
On Thursday, November 29, 2018 at 6:49:30 PM UTC+7, Patrick Ruckstuhl wrote:
Not really I'm accessing different markets which have different times and some don't have a price every day, so the price date might be a previous day.

Sure, I do that, too. I'm still not seeing the problem. Run bean-price and use the price at that time. Why does it matter if you store an intraday price? What do you think happens when you buy or sell something in beancount? The intraday price gets added to the price map. I don't think beancount is really meant for use cases where the difference between the price at 3pm and 4:30pm is material.

Anyway, it is really bothers you to have intraday prices then wait a day, or a week, and then use bean-price to get the prices from 2 or 3 days using the -d parameter once everything is closed & finalized.

Or run bean-price twice a day (or four times a day) and only fetch prices for markets that are closed when you run it.

I'm honestly kind of struggling to understand what explicit support you're looking for from bean-price here. Can you elaborate on that a bit? What's the exact usage you envision from beancount?

Martin Blais

unread,
Nov 29, 2018, 9:13:26 AM11/29/18
to bean...@googlegroups.com
On Thu, Nov 29, 2018 at 9:06 AM Justus Pendleton <just...@gmail.com> wrote:
On Thursday, November 29, 2018 at 6:49:30 PM UTC+7, Patrick Ruckstuhl wrote:
Not really I'm accessing different markets which have different times and some don't have a price every day, so the price date might be a previous day.

Sure, I do that, too. I'm still not seeing the problem. Run bean-price and use the price at that time. Why does it matter if you store an intraday price? What do you think happens when you buy or sell something in beancount? The intraday price gets added to the price map. I don't think beancount is really meant for use cases where the difference between the price at 3pm and 4:30pm is material.

That's correct.
(Well, the correct price will be attached to the Posting object, but for computing market value, there's one price/day.)


Anyway, it is really bothers you to have intraday prices then wait a day, or a week, and then use bean-price to get the prices from 2 or 3 days using the -d parameter once everything is closed & finalized.

For intra-day values you can upload your portfolio contents to a google sheets doc and feed live prices.
That's what I do.
My code for it is located here (it's a little bit custom, you may need to add similar metadata fields):
 

Or run bean-price twice a day (or four times a day) and only fetch prices for markets that are closed when you run it.

I'm honestly kind of struggling to understand what explicit support you're looking for from bean-price here. Can you elaborate on that a bit? What's the exact usage you envision from beancount?

I'm also a little bit confused.


Patrick Ruckstuhl

unread,
Nov 29, 2018, 10:09:22 AM11/29/18
to bean...@googlegroups.com, Martin Blais
Let my try to explain what I'm trying to do,
maybe I'm looking at things wrongly.
I would like to have a local price database. I do this with beancount files with price directives. What I'm now looking at is how to update this price files. They basically contain one entry per day and are updated daily. But on a daily run it can return a price date which already exists and I'm looking at a way to update (or maybe ignore) that entry.

I would also like all the price directives be in my base ccy as this then allows me simple reports as I know that I have prices to base ccy for everything. Here the problem is that some price sources will return the price in another ccy and I have to first convert it into my base ccy before creating the price entry.

I can create a script which does all that thing, I wad just wondering if there is a better/easier way than to create my own script.

Justus Pendleton

unread,
Nov 30, 2018, 8:23:31 AM11/30/18
to Beancount
On Thursday, November 29, 2018 at 10:09:22 PM UTC+7, Patrick Ruckstuhl wrote:
I would like to have a local price database. I do this with beancount files with price directives. What I'm now looking at is how to update this price files. They basically contain one entry per day and are updated daily. But on a daily run it can return a price date which already exists and I'm looking at a way to update (or maybe ignore) that entry.

bean-price has a --clobber flag "Do not skip prices which are already present in input files; fetch them anyway." I'm not sure that's exactly what you're looking for, though. I think you'll need to write a script to what you're looking for.

Patrick Ruckstuhl

unread,
Dec 4, 2018, 2:57:54 PM12/4/18
to bean...@googlegroups.com

Hi,

I'm now mostly done with the price imports. Thanks to the info you guys provided I think I'm able to solve my issues.

Maybe interesting for others could be the way I solved my "prices in base ccy" issue. I'm now going to store the price entries in the ccy as fetched from the price source and then created a very simple plugin, which takes that price, takes the fx rate and creates a new price entry in the base ccy.


Thanks again for the help,

Patrick

--
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/fd11025b-ded6-481e-bd5c-868c58836e3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages