Ledger CLI


Recently I have been using Ledger for managing my personal finances. It's been a short period but based on the proposal of the program I probably will stick with it for life.

Personal finance is a tough topic, each person handles it differently. I follow the YNAB approach.

Ledger follows a plain text accounting format. Using a text file to record every transaction with a double entry accounting style. Then we use the ledger cli program to query this data and see how much money is in each account, what are the transactions, etc.

It's also very flexible. It supports multiple currencies and you can even create your own. If I want I can track each single gold I have on World of Warcraft across multiple characters and server as well as have my personal finances in the middle.

Due to being a simple text file I can heavily automate the process of extracting a CSV with the transactions from my account and input on ledger.

A Little Taste

Just to show what is capable we can create this simple file data.dat containing some transactions:

2023/01/01 * Initial Balance
    Asset:Chase:Checking        $1000.00
    Asset:Chase:Saving          $2000.00
    Investing:Charles Schwab    100 AAPL ; Apple stock
    Investing:Charles Schwab    100 DIS  ; Disney stock
    Equity                      -$3000.00
    Equity                      -100 AAPL
    Equity                      -100 DIS

2023/01/02 * Domino's
    Expenses:Food:Delivery      $15.00
    Asset:Chase:Checking        ;; notice how I can hide the $-15.00 if I want

2023/01/03 * Interest
    Asset:Chase:Saving          = $2001.00 ;; I don't need to calculate the Interest. I can just say that today has 2001.00 and it will do the math
    Interest:Bank

Now I can run some queries to this data:

ledger -f data.dat balance

and it returns

            $2986.00  Asset:Chase
             $985.00    Checking
            $2001.00    Saving
           $-3000.00
           -100 AAPL
            -100 DIS  Equity
              $15.00  Expenses:Food:Delivery
              $-1.00  Interest:Bank
            100 AAPL
             100 DIS  Investing:Charles Schwab
--------------------
                   0

Double entry accounting will always result in zero. A more interesting question is How much do I have in my bank account?

ledger -f data.dat balance ^Asset

This will filter for only accounts that start with Asset.

            $2986.00  Asset:Chase
             $985.00    Checking
            $2001.00    Saving
--------------------
            $2986.00

List all transactions for my bank accounts

ledger -f data.dat register ^Asset
23-Jan-01 Initial Balance                      Asset:Chase:Checking                                     $1000.00               $1000.00
                                               Asset:Chase:Saving                                       $2000.00               $3000.00
23-Jan-02 Domino's                             Asset:Chase:Checking                                      $-15.00               $2985.00
23-Jan-03 Interest                             Asset:Chase:Saving                                          $1.00               $2986.00

There is much more you can do with it, but I'm not writing a tutorial for it 😁.