Cost basis adjustment for average cost booking

576 views
Skip to first unread message

Ceri Storey

unread,
Feb 11, 2024, 4:15:41 PM2/11/24
to Beancount
Hi folks,

I'm in the UK, so we get to deal with the inconvenience that is average cost booking when it comes to figuring out capital gains taxes. I'm currently using the average cost plugin, which works fine, but that approach it means that the inventory never gets reduced, so you end up with holdings never really going away.

So I was planning on using a cost-basis adjustment approach (https://beancount.github.io/docs/trading_with_beancount.html#cost-basis-adjustment-and-return-of-capital) to "re-base" the assets to have a single average cost basis. In this case, the asset is purchasable on a fractional basis.

So I've tried something like this:

2020-12-07 open Assets:Fnord:Foo                                                FOO
2020-12-07 open Assets:Fnord:Cash                                               GBP

2020-12-07 * "Buy Asset"
    Assets:Fnord:Cash                                                     -6.86 GBP
    Assets:Fnord:Foo                                                     5.5555 FOO  {1.2345 GBP}

2021-04-07 * "Buy more asset"
    Assets:Fnord:Cash                                                    -30.80 GBP
    Assets:Fnord:Foo                                                    13.1313 FOO  {2.3456 GBP}

2021-04-11 * "Average cost re-base"
    ; Re-base to current average cost basis
    Assets:Fnord:Foo                                                    -5.5555 FOO  {1.2345 GBP}
    Assets:Fnord:Foo                                                   -13.1313 FOO  {2.3456 GBP}
    ; Actual average is 2.015275062075903846565490079, according to python's decimal module.
    Assets:Fnord:Foo                                                     5.5555 FOO  {2.0152 GBP}
    Assets:Fnord:Foo                                                    13.1313 FOO  {2.0152 GBP}


No matter how much precision I specify for the average, it always seems to be off by some small amount:

/Users/cez/Documents/beancount/ledger/cost-basis-simple.beancount:12:      Transaction does not balance: (-0.00140267 GBP)

If I use an average of 2.015, -0.0051. Even with the 20 decimal places of precision for the average price, the transaction is off by -0.000000000000000000102592 GBP.

So I'm clearly missing something about the precision, and/or how to handle these cost basis adjustments. Can anyone offer any suggesiton as to what I might be missing? Is this one of those cases where I should post an adjustment to a hack account of some kind?

Thanks,

Martin Blais

unread,
Feb 11, 2024, 5:46:47 PM2/11/24
to bean...@googlegroups.com
What it should be: precision has to be rewritten (the v3 proposal includes ideas for doing this)
Practical solution: just add a little Equity:RoundingError posting to absorb the fraction of a cent and move on.

One day, when I retire, I'll spend months writing v3 and offer you all a new and improved Beancount or maybe someone with more free time and enthusiasm will beat me to it, go Crustaceans, go!).




--
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/db6e8cec-1ed5-49e9-b587-4719d1a90f54n%40googlegroups.com.

Ceri Storey

unread,
Feb 11, 2024, 6:07:14 PM2/11/24
to Beancount
> Practical solution: just add a little Equity:RoundingError posting to absorb the fraction of a cent and move on.

Great, that works for me. One down, umpteen to go.

Chary Chary

unread,
Feb 12, 2024, 4:15:33 PM2/12/24
to Beancount
On Sunday, February 11, 2024 at 6:46:47 PM UTC+1 bl...@furius.ca wrote:

One day, when I retire, I'll spend months writing v3 and offer you all a new and improved Beancount or maybe someone with more free time and enthusiasm will beat me to it, go Crustaceans, go!).



Martin, but you will not leave us completely alone until after your retirement, will you?

 

Martin Blais

unread,
Feb 14, 2024, 4:16:40 AM2/14/24
to bean...@googlegroups.com
Not completely, but as you've seen in the last couple of years, there isn't much time anymore.
(Maybe I can use Beancount v3 as an easy and familiar project to learn Rust with.)

Chary Chary

unread,
Feb 14, 2024, 10:37:08 AM2/14/24
to Beancount

(Maybe I can use Beancount v3 as an easy and familiar project to learn Rust with.)


Sounds like a very good idea
 

Ceri Storey

unread,
Feb 14, 2024, 11:59:16 AM2/14/24
to Beancount
> (Maybe I can use Beancount v3 as an easy and familiar project to learn Rust with.)

I've considered building a beancount clone myself (usually this lasts until I remember just how much work the current implementation represents). One option I've considered is porting v2 a module at a time using PyO3 or similar. But to be fair, a big part of that is that I wrote some C++ twenty years ago and it's terrified me ever since.

Stefano Zacchiroli

unread,
Feb 14, 2024, 8:53:20 PM2/14/24
to bean...@googlegroups.com
On Sun, Feb 11, 2024 at 12:46:00PM -0500, Martin Blais wrote:
> Practical solution: just add a little Equity:RoundingError posting to
> absorb the fraction of a cent and move on.

Do people usually use Equity as top-level category for rounding errors?
(And is there a relevant best practice from good accounting practices?)

I'm using Expenses myself, but it is indeed annoying, because some times
one ends up recording negative expenses...

Cheers
--
Stefano Zacchiroli . za...@upsilon.cc . https://upsilon.cc/zack _. ^ ._
Full professor of Computer Science o o o \/|V|\/
Télécom Paris, Polytechnic Institute of Paris o o o </> <\>
Co-founder & CTO Software Heritage o o o o /\|^|/\
https://twitter.com/zacchiro . https://mastodon.xyz/@zacchiro '" V "'

Martin Blais

unread,
Feb 14, 2024, 11:48:11 PM2/14/24
to bean...@googlegroups.com
I agree it's totally possible to rewrite a plain-text accounting system on your own in a short amount of time and there are many such projects on github but going all the way to handling a bunch of the corner cases, dealing with user issues continuously for a while, and making it extensible via plugins and other things are what gives it value IMHO. It's not hard, it's just a lot of perseverance. I spent a *lot* of weekends on this somehow, I really wanted to have this working well. It's far from done and perfect, all I see are the pain points...  it's annoying me a lot but I have no cycles.


--
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.

Chary Chary

unread,
Feb 15, 2024, 9:29:59 AM2/15/24
to Beancount
On Thursday, February 15, 2024 at 12:48:11 AM UTC+1 bl...@furius.ca wrote:
I agree it's totally possible to rewrite a plain-text accounting system on your own in a short amount of time and there are many such projects on github but going all the way to handling a bunch of the corner cases, dealing with user issues continuously for a while, and making it extensible via plugins and other things are what gives it value IMHO. It's not hard, it's just a lot of perseverance. I spent a *lot* of weekends on this somehow, I really wanted to have this working well. It's far from done and perfect, all I see are the pain points...  it's annoying me a lot but I have no cycles.

Martin, what you have done is very impressive. The quality of the documentation alone is something very special even for a commercial project, not to mention the "hobby" project. The spinning out of beanprice, beanquery and beangulp in v3 to separate projects I think is also a very important move to ease contributing by others.

What is important for me personally as a hobby pythinista is that you used functional programming approach, which allows mortals like me to get my head around the code. As an opposite I once tried to understand the pdfminer.six for instance, which has an object-oriented design. This appeared to be just beyond my abilities. 
 

fin

unread,
Feb 15, 2024, 4:30:37 PM2/15/24
to bean...@googlegroups.com
Chary Chary wrote:
> ------=_Part_56514_2020137454.1707989399485
> Content-Type: multipart/alternative;
> boundary="----=_Part_56515_2114565744.1707989399485"
>
> ------=_Part_56515_2114565744.1707989399485
> Content-Type: text/plain; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable


I certainly understand not having enough time or cycles to
work on big projects these days. In the warmer weather I have
a lot of gardens to keep after and then dealing with the
harvest and processing. So it isn't until the winter months
when I have more time to get back to any other more technical
projects.

With beancount I've been making progress and getting more
caught up to date historically which is interesting to me. I
just finished up getting my longest term account all brought
up to date, but I had some stubs in places that now I have to
go back and find and get things linked up properly. I love
big puzzles so this is actually fun for me when I can get to
it.

As far as coding goes, I'm not up to speed in C++ at all,
I have minor skill in Python, I do know C and many other
computing languages, but Rust I've done very little with
so far so I doubt I'd try to tackle a big project from the
start with it, but I do know I could probably learn it.
Just that it takes a few years of regular efforts to really
get good at a language.

So I would be willing to help out, but I would not be able
to make promises about time involvement. I'm just not at
that stage of things here right now.

Chary, I am also more functional programming oriented from
my work history (I've written large programs in Pascal, C,
and a few other languages, plus did a lot various things with
databases and SQL, etc.). OOP came along towards the end of
my heavy lifting as a coder and I did not get into it so to
pick up Python all these years later has been interesting
but I will not pretend to be proficient in it.

I don't have any doubts that I could do quite a bit with
C++ if I had to, but not likely now.

In terms of projects like beancount it is well worth having
the language defined and then using the right tools to
generate the parser for the language and then you can hang
the rest of your code off that. I don't know what Rust might
have in terms of those kinds of tools, but they do exist for
other languages. I'd hate to have to reinvent the wheel yet
again (I've written a lot of parsers/lexical analysers) if
the language for beancount is already well defined.

fin


> On Thursday, February 15, 2024 at 12:48:11=E2=80=AFAM UTC+1 bl...@furius.ca=
> wrote:
>
> I agree it's totally possible to rewrite a plain-text accounting system on=
>=20
> your own in a short amount of time and there are many such projects on=20
> github but going all the way to handling a bunch of the corner cases,=20
> dealing with user issues continuously for a while, and making it extensible=
>=20
> via plugins and other things are what gives it value IMHO. It's not hard,=
>=20
> it's just a lot of perseverance. I spent a *lot* of weekends on this=20
> somehow, I really wanted to have this working well. It's far from done and=
>=20
> perfect, all I see are the pain points... it's annoying me a lot but I=20
> have no cycles.
>
>
> Martin, what you have done is very impressive. The quality of the=20
> documentation alone is something very special even for a commercial=20
> project, not to mention the "hobby" project. The spinning out of beanprice,=
>=20
> beanquery and beangulp in v3 to separate projects I think is also a very=20
> important move to ease contributing by others.
>
> What is important for me personally as a hobby pythinista is that you used=
>=20
> functional programming approach, which allows mortals like me to get my=20
> head around the code. As an opposite I once tried to understand the=20
> pdfminer.six <https://github.com/pdfminer/pdfminer.six> for instance, which=
>=20
> has an object-oriented design. This appeared to be just beyond my=20
> abilities.=20
>=20
>
> --=20
> 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 e=
> mail to beancount+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/=
> beancount/52a9a27d-2539-41f6-ac19-39d2bcfab7aan%40googlegroups.com.
>
> ------=_Part_56515_2114565744.1707989399485
> Content-Type: text/html; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
><br /><br /><div><div dir=3D"auto">On Thursday, February 15, 2024 at 12:48:=
> 11=E2=80=AFAM UTC+1 bl...@furius.ca wrote:<br /></div><blockquote style=3D"=
> margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204, 204); paddi=
> ng-left: 1ex;"><div dir=3D"ltr"><div style=3D"font-family: arial, sans-seri=
> f; font-size: small;">I agree it's totally possible to rewrite a plain-text=
> accounting system on your own in a short amount of time and there are many=
> such projects on github but going all the way to handling a bunch of the c=
> orner cases, dealing with user issues continuously for a while, and making =
> it extensible via plugins and other things are what gives it value IMHO. It=
> 's not hard, it's just a lot of perseverance. I spent a *lot* of weekends o=
> n this somehow,=C2=A0I really wanted to have this working well. It's far fr=
> om done and perfect, all I see are the pain points...=C2=A0 it's annoying m=
> e a lot but I have no cycles.</div></div></blockquote><div><br /></div><div=
>>Martin, what you have done is very impressive. The quality of the document=
> ation alone is something very special even for a commercial project, not to=
> mention the "hobby" project. The spinning out of beanprice, beanquery and =
> beangulp in v3 to separate projects I think is also a very important move t=
> o ease contributing by others.</div><div><br /></div><div>What is important=
> for me personally as a hobby pythinista is that you used functional progra=
> mming approach, which allows mortals like me to get my head around the code=
> . As an opposite I once tried to understand the=C2=A0<a href=3D"https://git=
> hub.com/pdfminer/pdfminer.six">pdfminer.six</a>=C2=A0for instance, which ha=
> s an object-oriented design. This appeared to be just beyond my abilities.=
>=C2=A0</div><div>=C2=A0</div></div>
>
><p></p>
>
> -- <br />
> You received this message because you are subscribed to the Google Groups &=
> quot;Beancount&quot; group.<br />
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to <a href=3D"mailto:beancount+...@googlegroups.com">beancount=
> +unsub...@googlegroups.com</a>.<br />
> To view this discussion on the web visit <a href=3D"https://groups.google.c=
> om/d/msgid/beancount/52a9a27d-2539-41f6-ac19-39d2bcfab7aan%40googlegroups.c=
> om?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgi=
> d/beancount/52a9a27d-2539-41f6-ac19-39d2bcfab7aan%40googlegroups.com</a>.<b=
> r />
>
> ------=_Part_56515_2114565744.1707989399485--
>
> ------=_Part_56514_2020137454.1707989399485--
>

Chary Chary

unread,
Apr 3, 2024, 8:04:45 AM4/3/24
to Beancount
On Sunday, February 11, 2024 at 6:46:47 PM UTC+1 bl...@furius.ca wrote:
....
Practical solution: just add a little Equity:RoundingError posting to absorb the fraction of a cent and move on.

Martin,

are there any serious consequences of just ignoring such tiny values balance errors?
 
Under consequence I would mean, that beanquery would for instance completely ignore such a transaction.



Martin Blais

unread,
Apr 4, 2024, 1:34:23 AM4/4/24
to bean...@googlegroups.com
On Wed, Apr 3, 2024 at 4:04 AM Chary Chary <char...@gmail.com> wrote:


On Sunday, February 11, 2024 at 6:46:47 PM UTC+1 bl...@furius.ca wrote:
....
Practical solution: just add a little Equity:RoundingError posting to absorb the fraction of a cent and move on.

Martin,

are there any serious consequences of just ignoring such tiny values balance errors?
No.
The worse that could happen is that a larger balance gets accidentally absorbed by this posting (when used without an amount).
This could be asserted by a plugin.


 
 
Under consequence I would mean, that beanquery would for instance completely ignore such a transaction.



--
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.

Chary Chary

unread,
Apr 4, 2024, 7:45:25 PM4/4/24
to Beancount
On Thursday, April 4, 2024 at 3:34:23 AM UTC+2 bl...@furius.ca wrote:

are there any serious consequences of just ignoring such tiny values balance errors?
No.
The worse that could happen is that a larger balance gets accidentally absorbed by this posting (when used without an amount).
This could be asserted by a plugin.


Martin,

can you please elaborate more on this?

I was reading your answer again and again,  but I just don't get it

How can something larger can be   gets accidentally absorbed by something tiny?

How can posting be without an amount (I understand, it can be without price or cost, but how without amount?)


Martin Blais

unread,
Apr 4, 2024, 9:21:02 PM4/4/24
to bean...@googlegroups.com
On Thu, Apr 4, 2024 at 3:45 PM Chary Chary <char...@gmail.com> wrote:
On Thursday, April 4, 2024 at 3:34:23 AM UTC+2 bl...@furius.ca wrote:
are there any serious consequences of just ignoring such tiny values balance errors?
No.
The worse that could happen is that a larger balance gets accidentally absorbed by this posting (when used without an amount).
This could be asserted by a plugin.


Martin,

can you please elaborate more on this?

I was reading your answer again and again,  but I just don't get it

If you just put a posting with no amount it'll automatically get filled by the remaining amount, no matter how large.
Ideally you'd want to have some sort of warning in case that's larger than whatever is small enough to be considered a rounding amount.
There is none at the moment.


 

How can something larger can be   gets accidentally absorbed by something tiny?

How can posting be without an amount (I understand, it can be without price or cost, but how without amount?)


--
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.

Chary Chary

unread,
Apr 5, 2024, 2:43:25 PM4/5/24
to Beancount
On Thursday, April 4, 2024 at 11:21:02 PM UTC+2 bl...@furius.ca wrote:


If you just put a posting with no amount it'll automatically get filled by the remaining amount, no matter how large.
Ideally you'd want to have some sort of warning in case that's larger than whatever is small enough to be considered a rounding amount.
There is none at the moment.

OK, thanks. it is clear 
 

fin

unread,
Apr 9, 2024, 12:40:56 PM4/9/24
to bean...@googlegroups.com
Martin Blais wrote:


Yes, that was how i read your comment, but I also thought
you were referencing a plugin which would generate an error
if needed.

Apropo to nothing other than talking about rounding errors -
up until now I've not had too many rounding issues with my
imported and converted transactions until the past few days.

The brokerage account has some rounding involved and one
amount they use can throw me off because I always use exact
amounts to as many decimals as needed in my own calculations.

So now I'm seeing an account where I'm off by a penny due to
rounding and the various amounts the brokerage uses but doesn't
keep consistent. I don't mind if they use a rounded value but
I do want them to be consistent about it and not reporting one
value in one place and another value in another and yet another
in a third place (41.05 != 41.0501 != 41.0502).

And even with the strange stuff going on I still have no
values ever showing up in Equity:RoundingError even if I am
using options "inferred_tolerance_default" "*:0.000001" and
option "account_rounding" "Equity:RoundingError". I'd much
rather have a transaction that isn't balancing error out
right away so I can deal with it before building later
transactions upon an error.


fin


> --0000000000003f99c806154bea28
> Content-Type: text/plain; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
> On Thu, Apr 4, 2024 at 3:45=E2=80=AFPM Chary Chary <char...@gmail.com> wro=
> te:
>
>> On Thursday, April 4, 2024 at 3:34:23=E2=80=AFAM UTC+2 bl...@furius.ca wr=
> ote:
>>
>> are there any serious consequences of just ignoring such tiny values
>> balance errors?
>>
>> No.
>> The worse that could happen is that a larger balance gets accidentally
>> absorbed by this posting (when used without an amount).
>> This could be asserted by a plugin.
>>
>>
>> Martin,
>>
>> can you please elaborate more on this?
>>
>> I was reading your answer again and again, but I just don't get it
>>
>
> If you just put a posting with no amount it'll automatically get filled by
> the remaining amount, no matter how large.
> Ideally you'd want to have some sort of warning in case that's larger than
> whatever is small enough to be considered a rounding amount.
> There is none at the moment.
>
>
>
>
>>
>> How can something larger can be gets accidentally absorbed by something
>> tiny?
>>
>> How can posting be without an amount (I understand, it can be without
>> price or cost, but how without amount?)
>>
>>
>> --
>> 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/18d5480c-0fcc-4b95-a176-dd92b=
> f8e10a9n%40googlegroups.com
>> <https://groups.google.com/d/msgid/beancount/18d5480c-0fcc-4b95-a176-dd92=
> bf8e10a9n%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter>
>> .
>>
>
> --=20
> 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 e=
> mail to beancount+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/=
> beancount/CAK21%2BhNCCkHQK3nLZE8QLhJ6-jcdWJAcK-_utC2PygGkpb9xnQ%40mail.gmai=
> l.com.
>
> --0000000000003f99c806154bea28
> Content-Type: text/html; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
><div dir=3D"ltr"><div dir=3D"ltr"><div class=3D"gmail_default" style=3D"fon=
> t-family:arial,sans-serif;font-size:small"><span style=3D"font-family:Arial=
> ,Helvetica,sans-serif">On Thu, Apr 4, 2024 at 3:45=E2=80=AFPM Chary Chary &=
> lt;<a href=3D"mailto:char...@gmail.com">char...@gmail.com</a>&gt; wrote:<=
> /span></div></div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quo=
> te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204=
> );padding-left:1ex"><div><div dir=3D"auto">On Thursday, April 4, 2024 at 3:=
> 34:23=E2=80=AFAM UTC+2 <a href=3D"mailto:bl...@furius.ca" target=3D"_blank"=
>>bl...@furius.ca</a> wrote:</div><blockquote style=3D"margin:0px 0px 0px 0.=
> 8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"lt=
> r"><div><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid=
> rgb(204,204,204);padding-left:1ex"><div><div>are there any serious consequ=
> ences of just ignoring such tiny values balance errors?</div></div></blockq=
> uote></div></div><div dir=3D"ltr"><div><div><div style=3D"font-family:arial=
> ,sans-serif;font-size:small"></div><div style=3D"font-family:arial,sans-ser=
> if;font-size:small">No.</div><div style=3D"font-family:arial,sans-serif;fon=
> t-size:small">The worse that could happen is that a larger balance gets acc=
> identally absorbed by this posting (when used without an amount).</div><div=
> style=3D"font-family:arial,sans-serif;font-size:small">This=C2=A0could be =
> asserted by a plugin.</div><div style=3D"font-family:arial,sans-serif;font-=
> size:small"><br></div></div></div></div><div dir=3D"ltr"><div><blockquote s=
> tyle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pad=
> ding-left:1ex"><br></blockquote></div></div></blockquote><div>Martin,</div>=
><div><br></div><div>can you please elaborate more on this?</div><div><br></=
> div><div>I was reading your answer again and again,=C2=A0 but I just don&#3=
> 9;t get it</div></div></blockquote><div><br></div><div><div class=3D"gmail_=
> default" style=3D"font-family:arial,sans-serif;font-size:small">If you just=
> put a posting with no amount it&#39;ll automatically get filled by the rem=
> aining amount, no matter how large.</div><div class=3D"gmail_default" style=
>=3D"font-family:arial,sans-serif;font-size:small">Ideally you&#39;d want to=
> have some sort of warning in case that&#39;s larger than whatever is small=
> enough to be considered a rounding amount.</div><div class=3D"gmail_defaul=
> t" style=3D"font-family:arial,sans-serif;font-size:small">There is none at =
> the moment.</div><div class=3D"gmail_default" style=3D"font-family:arial,sa=
> ns-serif;font-size:small"><br></div><br></div><div>=C2=A0</div><blockquote =
> class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px sol=
> id rgb(204,204,204);padding-left:1ex"><div><div><br></div><div>How can some=
> thing larger can be=C2=A0=C2=A0<span style=3D"font-family:arial,sans-serif;=
> font-size:small">=C2=A0</span><span style=3D"font-family:arial,sans-serif;f=
> ont-size:small">gets accidentally absorbed by something tiny?</span></div><=
> div><span style=3D"font-family:arial,sans-serif;font-size:small"><br></span=
>></div><div><span style=3D"font-family:arial,sans-serif;font-size:small">Ho=
> w can posting be without an amount (I understand, it can be without price o=
> r cost, but how without amount?)</span></div><div><span style=3D"font-famil=
> y:arial,sans-serif;font-size:small"><br></span></div><div><br></div></div>
>
><p></p>
>
> -- <br>
> You received this message because you are subscribed to the Google Groups &=
> quot;Beancount&quot; group.<br>
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to <a href=3D"mailto:beancount+...@googlegroups.com" target=3D=
> "_blank">beancount+...@googlegroups.com</a>.<br>
> To view this discussion on the web visit <a href=3D"https://groups.google.c=
> om/d/msgid/beancount/18d5480c-0fcc-4b95-a176-dd92bf8e10a9n%40googlegroups.c=
> om?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">https://gr=
> oups.google.com/d/msgid/beancount/18d5480c-0fcc-4b95-a176-dd92bf8e10a9n%40g=
> ooglegroups.com</a>.<br>
></blockquote></div></div>
>
><p></p>
>
> -- <br />
> You received this message because you are subscribed to the Google Groups &=
> quot;Beancount&quot; group.<br />
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to <a href=3D"mailto:beancount+...@googlegroups.com">beancount=
> +unsub...@googlegroups.com</a>.<br />
> To view this discussion on the web visit <a href=3D"https://groups.google.c=
> om/d/msgid/beancount/CAK21%2BhNCCkHQK3nLZE8QLhJ6-jcdWJAcK-_utC2PygGkpb9xnQ%=
> 40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goo=
> gle.com/d/msgid/beancount/CAK21%2BhNCCkHQK3nLZE8QLhJ6-jcdWJAcK-_utC2PygGkpb=
> 9xnQ%40mail.gmail.com</a>.<br />
>
> --0000000000003f99c806154bea28--
>

Simon Michael

unread,
Apr 26, 2024, 11:55:18 PM4/26/24
to bean...@googlegroups.com
On 2024-02-15 06:29, fin wrote:
> In terms of projects like beancount it is well worth having
> the language defined and then using the right tools to
> generate the parser for the language and then you can hang
> the rest of your code off that. I don't know what Rust might
> have in terms of those kinds of tools, but they do exist for
> other languages. I'd hate to have to reinvent the wheel yet
> again (I've written a lot of parsers/lexical analysers) if
> the language for beancount is already well defined.

I expect Rust has very good parsing tools. Are the semantics of
Beancount's journal format straightforward enough that those standard
tools can be used ?

(For hledger and especially Ledger it's not the case, and custom parser
code is needed.)

Jonathan Niven

unread,
Oct 8, 2024, 10:37:25 AM10/8/24
to Beancount
I am also in the UK and have come up with the following for using STRICT booking with rebalancing and labels for lots:

2020-12-07 * "Buy Asset"
    Assets:Fnord:Cash                                                     -6.86 GBP
    Assets:Fnord:Foo                                                     5.5555 FOO  {1.2345 GBP, "buy1"}


2021-04-07 * "Buy more asset"
    Assets:Fnord:Cash                                                    -30.80 GBP
    Assets:Fnord:Foo                                                    13.1313 FOO  {2.3456 GBP, "buy2"}


2021-04-11 * "Average cost re-base"
    ; Re-base to current average cost basis
    Assets:Fnord:Foo                                                    -5.5555 FOO  {"buy1"}
    Assets:Fnord:Foo                                                   -13.1313 FOO  {"buy2"}
    ; We let beancount handle the averaging for us
    Assets:Fnord:Foo                                                     (5.5555+13.1313) FOO  {"balance1"}


2021-04-07 * "Sell from holding"
    Assets:Fnord:Cash                                                   50 GBP
    Assets:Fnord:Foo                                                    -10 FOO  {"balance1"}

Any sale I make that matches the S104 holding will always be against one of the "balance" labels. I don't need to worry about rounding etc, but I still have to manually track the exact units of the commodity I'm buying/selling
Reply all
Reply to author
Forward
0 new messages