Skip to content

Why knut

Silvio Böhler edited this page Jan 5, 2021 · 4 revisions

Why knut

beans is the original implementation in Haskell, but then it turned out so that Go is paying my bills at the moment. So when I started to learn Go at the beginning of the year, I rewrote beans' parser for fun and exercise. And I liked it and kept going, found a new name, and when I got to the point that knut had more features than beans, I simply put it up on github as knut. beans is therefore obsolete, as I am not using it anymore, and knut's syntax has moved away significantly in the meantime.

Go is very convenient in that I can easily release binaries for people to try out, it works on all major operating systems, and is far more hackable to the interested public than Haskell (I've read this poor soul's account of nix and stack hell with compassion: https://forum.mustachianpost.com/t/beancount-advancement-thread/2786)

Maybe I should just delete the beans repository, but I don't like the idea of breaking people's links, and it is a nice reference still.

Motivation

The main motivation for writing my own tool is because it is a lot of fun! The code is small and I can experiment at will:

  • I just recently changed the syntax to a scheme which I like much better, and which hopefully will be the basis for computing portfolio returns at some point in the future.

  • I introduced "value" directives which are great to model opaque portfolios (such as my VIAC account). Instead of modeling it bottom up, I only import the daily value, and together with the explicitly modeled cash flows from my bank account I have the complete picture to analyze gains and losses.

I have many more ideas for the future (time weighted / money weighted portfolio returns, allocation analysis by commodity, declarative accrual accounting), which I could probably not realize in other tools.

Other tools are much more complex, with lots of special cases and support for features I don't need. For example, there is no capital gains tax for nonprofessional individual investors in Switzerland, so knut's support for lots is almost nonexistent.

The other motivation is that my use cases seem not to be well supported by other tools. 

Tables

For one, I started out with tracking everything in Access / Excel many years ago, and I like tabular, columnar reports like the ones you can see in the examples). Aggregation by year, month, quarter or day is a must-have for me, I had difficulties creating those in other tools, but knut can print this report using a few simple flags: 

knut balance <journal> --last 6 --months knut balance <journal> --last 6 --days

Day to day, that's usually all I need (although I love to have a web based reporting interface at some point)

Investment tracking

Also, I am heavily investing in securities, and I need robust reporting of unrealized gains, i.e. valuation at latest market prices at the time of the position. knut / beans can valuate an entire multi-column report in arbitrary commodities, and the accounting equation is always satisfied (i.e. A+L+E+Inc+Exp = 0).

Every change in value of a position is being modeled behind the scenes using an auto-generated valuation transaction. In this example (https://github.com/sboehler/knut#monthly-balance-in-a-given-commodity), the Equity:Valuation line tracks the cumulative valuation gains (losses).

I never managed to understand the accounting of valuation gains and losses in other tools, but in knut it is as simple as 

knut balance <journal> -v CHF

to valuate my entire balance correctly in my native currency (or any other asset, if required).

User base

As to the user base, I believe I am the only person using knut seriously at the moment. Rightfully so - it is really unstable and this is only my side project, not my job.

But I still want to put it out here so people can play around, see a different take on the plain text accounting theme, and take the ideas into other tools if they like. It's open source, so take what you need and do what you want with it!

For example, it would be quite easy for anybody who knows some basic Go to refactor them into beancount importers.

Clone this wiki locally