Hi Martin,

Beancount seems to round inferred numbers by default:

1970-01-01 open Assets:Cash
1970-01-01 open Assets:Positions
1970-01-01 open Expenses:Financial:Commissions

2018-03-29 * "Buy 10 BILI"
  Assets:Cash
  Assets:Positions                 10 BILI {11.4899 USD, 2018-03-29} @ 11.4899 
USD
  Expenses:Financial:Commissions  0.1 USD

turns into:

2018-03-29 * "Buy 10 BILI"
  Assets:Cash                     -115.0 USD
  Assets:Positions                    10 BILI {11.4899 USD, 2018-03-29} @ 
11.4899 USD
  Expenses:Financial:Commissions     0.1 USD

The full-precision number for Assets:Cash should be -114.9990 USD, but
it was incorrectly rounded to -115.0 USD.

In the documentation
https://docs.google.com/document/d/1lgHxUUEY-UVEgoF6cupz2f_7v7vEF7fiJyiSlYYlhOo/
section "Precision of Inferred Numbers":

> If the default tolerance is not overridden in the input file—and
> therefore is zero—the full precision will be used; no rounding occurs.

In the minimal example above, the precision seems to be inferred from
0.1 USD commission. If I change the input file, changing commission from
0.1 USD to 0.1000 USD, the output is correct:

2018-03-29 * "Buy 10 BILI"
  Assets:Cash                     -114.9990 USD
  Assets:Positions                       10 BILI {11.4899 USD, 2018-03-29} @ 
11.4899 USD
  Expenses:Financial:Commissions     0.1000 USD

My broker-dealer returns the commission as 0.1 USD because it is a
floating point number in JSON (you cannot end numbers with zeros). But
behind the scenes it calculates the cash balance with the full-precision
numbers (e.g. 0.1000 USD). After a few transactions, the balance of
Assets:Cash has a difference of more than 0.005 USD with the
broker-dealer and thus fails the balance assertion.

Is there a way to turn off the implicit rounding without padding 0.1 USD
to 0.1000 USD in the input file?

I am using tagged release 2.0.0.


-- 
Zhuoyun Wei

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/20180401091341.GA26139%40tarball.wzyboy.org.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: PGP signature

Reply via email to