I have create a simple PR 120 <https://github.com/beancount/beanprice/pull/120>, which I think fixes this (at least partially)
One can try it pip install git+https://github.com/Ev2geny/beanprice.git@issue_116 On Wednesday, June 4, 2025 at 1:17:54 AM UTC+2 Alen Šiljak wrote: > Thank you for that analysis! > For reference, I will also copy here the reply I added to that issue: > > Thanks for elaborating! I had the same issue. However, I searched for > decimal places > ```sql > select * where round(number, 6) != number > ``` > and there was no records with that many decimal places. I looked for both > `number` and `cost_number`. > I was debugging the `print` function but did not really figure out why all > the prices were maxed-out with zeros. The currency precision was different > for different currencies, while prices were all with almost the same number > of decimal places. > After I fixed the price source to return the decimals as reported on the > exchange (the source I was testing with was returning some crazy amounts > with multiple decimals, but max. 6, not 18), the places were padded with > 0's. > After reading your description, I assume the decimal places were jacked-up > by implicit prices, since I'm using > ``` > plugin "beancount.plugins.implicit_prices" > ``` > in my book. But that is still just an assumption. > > Based on the recent check-ins, Martin is working on the precision setting > so that might eventually resolve the problem. > > As a workaround, I wrote a simple script that strips the right-most zeros > from the prices in the generated price file. This will work for now, as I'm > focusing on completing the importers and other price sources. > > On Wednesday, 4 June 2025 at 12:24:47 am UTC+2 Chary Ev2geny wrote: > >> Hi, >> >> I also saw similar problem, so I now documented on how to reproduce it >> >> https://github.com/beancount/beanprice/issues/116 >> >> Regards. >> >> On Friday, May 30, 2025 at 5:10:05 PM UTC+2 Alen Šiljak wrote: >> >>> Hi! I've set up beanprice to fetch prices and that seems to work. I've >>> also adapted some of my price sources to work with beancount. These are >>> publicly available as as-price-download on github/pypi. >>> >>> When running directly >>> ```sh >>> bean-price -e "AUD:pricedl.beanprice.yahoo/ASX:VHY" >>> ``` >>> the price comes out as expected >>> ``` >>> 2025-05-30 price ASX:VHY 74.33 AUD >>> ``` >>> But, when reading the metadata from the book >>> ``` >>> bean-price -v ..\book.bean > ..\prices\prices.current.bean >>> ``` >>> the prices are coming out like this: >>> ``` >>> 2025-05-30 price BLV 67.6500000000000000000000000000 >>> USD >>> 2025-05-30 price BND 72.6350000000000000000000000000 >>> USD >>> 2025-05-29 price BRF 14.5922000000000000000000000000 >>> USD >>> 2025-05-30 price BSV 78.2699966430664062500000000000 >>> USD >>> 2025-05-30 price CEMB 44.8699989318847656250000000000 >>> USD >>> 2025-05-30 price CQE_AX 2.960000038146972656250000000 AUD >>> ``` >>> These are from two different sources. Mine has 4 decimals, so likely >>> using a different API. >>> Is there a way to limit the number of decimal places and/or to get rid >>> of the zeros? >>> In the price source I've written, the price is Decimal type. So, the >>> output and the conversion to string happens somewhere in beanprice, I >>> assume? >>> >>> Somebody elsewhere suggested that this is due to the existing prices and >>> inference. I will try to experiment with one symbol. >>> >>> Any hints highly appreciated! >>> >> -- 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 [email protected]. To view this discussion visit https://groups.google.com/d/msgid/beancount/485c9917-fafa-466d-b5cc-5d0f20773efen%40googlegroups.com.
