Beancount Example & Tutorial

354 views
Skip to first unread message

Martin Blais

unread,
Oct 12, 2014, 7:33:33 PM10/12/14
to bean...@googlegroups.com, ledger-cli
Hi,

I've implemented an example generator script for Beancount:

This script can be used to generate several years of a realistic person's financial transaction history. The characteristics of the ledger produced by the script is described in the new basic tutorial I just wrote:

A run of the example generator outputs something like this:

I'll be using this script...

- In examples, to make illustrative queries on a realistic anonymous input file, to explain things;

- As the example file for Beancount's tutorial commands;

- As a basis for a converter to Ledger syntax, so that we can compare report outputs. You can convert Beancount input to Ledger input with "bean-query filename.beancount ledger > filename.lgr";

- For stress testing (eventually).

If anyone finds this useful, let me know.
Cheers,

Simon Michael

unread,
Oct 13, 2014, 9:46:20 PM10/13/14
to ledge...@googlegroups.com, bean...@googlegroups.com
On 10/12/14 4:33 PM, Martin Blais wrote:
> I've implemented an example generator script for Beancount:
> https://bitbucket.org/blais/beancount/src/tip/src/python/beancount/scripts/example.py
...
> A run of the example generator outputs something like this:
> https://bitbucket.org/blais/beancount/src/tip/examples/tutorial/example.beancount

Very cool Martin!

I look forward to making hledger work with this and catching up on your
recent docs.


Simon Michael

unread,
Oct 13, 2014, 11:34:48 PM10/13/14
to ledge...@googlegroups.com, bean...@googlegroups.com, hle...@googlegroups.com
FWIW, I went ahead and commented the syntax hledger doesn't support yet
- beancount directives, org-mode nodes (what a good idea!) - and
converted {PRICE} to @ PRICE, after which hledger balance gives the same
results as ledger, except for the capital gain/lost accounts and some
whitespace.


Martin Blais

unread,
Oct 14, 2014, 1:18:21 AM10/14/14
to ledger-cli, bean...@googlegroups.com, hle...@googlegroups.com
Awesome stuff! :-)
I will adapt my converter.
Can you send me the modified file that is grokked by HLedger? 
I'll diff it and make sure the converter is able to replicate it.
Thanks,






--

--- You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Blais

unread,
Oct 18, 2014, 12:07:58 PM10/18/14
to hle...@googlegroups.com, ledger-cli, bean...@googlegroups.com
I made the necessary changes.
Basically it's just like Ledger but without the {cost} syntax.
So I replaced all these values by the price syntax.
So now Beancount is able to convert to HLedger's syntax variant as well as Ledger's.


mandarine [default]:~/p/beancount$ bean-query examples/tutorial/example.beancount hledger > /tmp/test.lgr && hledger -f /tmp/test.lgr bal                                                                                                                                                                                      
           70.00 GLD  
          17.00 ITOT  
489.957000000000 RGAGX  
         5716.53 USD  
        337.26 VACHR  
309.950000000000 VBMPX  
           36.00 VEA  
          294.00 VHT  Assets:US
          596.05 USD    BofA:Checking
           70.00 GLD    
          17.00 ITOT    
....






On Thu, Oct 16, 2014 at 1:15 PM, Simon Michael <si...@joyful.com> wrote:
On 10/13/14 10:18 PM, Martin Blais wrote:
Awesome stuff! :-)
I will adapt my converter.
Can you send me the modified file that is grokked by HLedger?
I'll diff it and make sure the converter is able to replicate it.

It's example.beancount.hledger at http://hledger.org/static/ .

Best - Simon


--
You received this message because you are subscribed to the Google Groups "hledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hledger+unsubscribe@googlegroups.com.

Simon Michael

unread,
Oct 18, 2014, 4:50:57 PM10/18/14
to public-hledger-/JY...@plane.gmane.org, ledger-cli, public-beancount-/J...@plane.gmane.org


On 10/18/14 9:07 AM, Martin Blais wrote:
> I made the necessary changes.
> Basically it's just like Ledger but without the {cost} syntax.
> So I replaced all these values by the price syntax.
> So now Beancount is able to convert to HLedger's syntax variant as well
> as Ledger's.
>
>
> mandarine [default]:~/p/beancount$ bean-query
> examples/tutorial/example.beancount hledger > /tmp/test.lgr && hledger
> -f /tmp/test.lgr bal
> 70.00 GLD
> 17.00 ITOT
> 489.957000000000 RGAGX
> 5716.53 USD
> 337.26 VACHR
> 309.950000000000 VBMPX
> 36.00 VEA
> 294.00 VHT Assets:US
> 596.05 USD BofA:Checking
> 70.00 GLD
> 17.00 ITOT
> ....

I think you've added a "hledger" subcommand to bean-query, which prints
out a beancount journal in hledger-compatible format - is that right ?


Martin Blais

unread,
Oct 18, 2014, 5:53:28 PM10/18/14
to hle...@googlegroups.com, ledger-cli, bean...@googlegroups.com
Yes




Simon Michael

unread,
Oct 21, 2014, 9:15:05 PM10/21/14
to ledge...@googlegroups.com, bean...@googlegroups.com, hle...@googlegroups.com, bean...@googlegroups.com, ledge...@googlegroups.com
On 10/18/14 2:53 PM, Martin Blais wrote:
> I think you've added a "hledger" subcommand to bean-query, which
> prints out a beancount journal in hledger-compatible format - is
> that right ?
>
> Yes

Nice!


Reply all
Reply to author
Forward
0 new messages