-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Issue
Under certain conditions beanprice displays prices with precision higher, than available from the data source. The extra precision is created by adding extra zeros, which does not provide any added value.
expected behavior
beanprice would never display prices with the precision higher, than received from a data source
How to reproduce
So far so good
ledger.beancount
2025-05-20 commodity AAPL
price: "USD:yahoo/AAPL"
bean-price ledger.beancount -i --update
Here the prices are displayed with the maximum available from the data source precision:
2025-05-20 price AAPL 206.86000061035156 USD
2025-05-21 price AAPL 202.08999633789062 USD
2025-05-22 price AAPL 201.36000061035156 USD
2025-05-23 price AAPL 195.27000427246094 USD
2025-05-23 price AAPL 195.27000427246094 USD
2025-05-27 price AAPL 200.2100067138672 USD
2025-05-28 price AAPL 200.4199981689453 USD
2025-05-29 price AAPL 199.9499969482422 USD
2025-05-30 price AAPL 200.85000610351562 USD
2025-06-02 price AAPL 201.6999969482422 USD
2025-06-03 price AAPL 203.27000427246094 USD
Let us now add some price entry in the file, which will help beanprice to derive expected precision (in our case no numbers after comma)
ledger.beancount
2025-05-20 commodity AAPL
price: "USD:yahoo/AAPL"
2025-05-28 price AAPL 200 USD
In this case beanprice displays prices with inferred precision even though a better precision is available. This makes sense
bean-price ledger.beancount -i --update
2025-05-29 price AAPL 200 USD
2025-05-30 price AAPL 201 USD
2025-06-02 price AAPL 202 USD
2025-06-03 price AAPL 203 USD
!!! Now the problem !!
If we try to artificially pump the expected precision
ledger.beancount
2025-05-20 commodity AAPL
price: "USD:yahoo/AAPL"
2025-05-28 price AAPL 200.00000000000000000000000000000000000000000000000000000000000000000000000 USD
Then beanprices tries to match it, even though this precision is not available from the data source
bean-price ledger.beancount -i --update
2025-05-29 price AAPL 199.94999694824220000000000000000000000000000000000000000000000000000000000 USD
2025-05-30 price AAPL 200.85000610351562000000000000000000000000000000000000000000000000000000000 USD
2025-06-02 price AAPL 201.69999694824220000000000000000000000000000000000000000000000000000000000 USD
2025-06-03 price AAPL 203.27000427246094000000000000000000000000000000000000000000000000000000000 USD
Notes
There is another similar issue available #92
It may or may not be the same, as the latter does not have much information on how to reproduce