Skip to content

Ledger

Ledger represents a book of financial transactions in an individual account or a group of accounts.

The app maintains a separate ledger per account with exception of migrated accounts. Transactions in accounts transferred between different branches of Interactive Brokers are automatically grouped together into a single ledger.

Get started

Let's start by creating a working directory for portfelj in the user home directory. Let's call it ibkr.

Create a subfolder ibkr/flex and copy all generated flex reports to it.

The folder structure may look as following if you have trade reports for the past few years:

sh
.
└─ flex
   ├─ 2025.xml
   ├─ 2024.xml
   └─ 2023.xml

Now open terminal and change current directory to ibkr:

sh
cd ibkr

You're all set! Try some examples below and run the app against your portfolio.

TIP

Make sure to backup this directory after each tax season, since data stored here is pretty important!

View trades chronologically

Run the following command to view chronological trade data as series of positions:

sh
portfelj ledger

View closing trades

List closing trades within the given year, with matching opening trades in the same or preceding year(s) based on FIFO order.

For example, let's list all closing trades in 2024:

sh
portfelj ledger --tax-year 2024

TIP

The data output of this mode is used for generation of tax returns for eDavki.

Search and filter output

It's possible to filter ledger output using either one or multiple filters:

  • By account ID

    For example only show trades in the account ID U7000001:

    sh
    portfelj ledger --account-id U7000001

    Replace U7000001 with the actual account ID

  • By symbol

    For example only show positions in APPL:

    sh
    portfelj ledger --symbol AAPL

Merge multiple accounts

By default, each account is treated separately and the output of ledger looks as series of accounts and positions.

One exception to that is when there is a link between accounts. For instance when the same account is moved between different branches of Interactive Brokers.

Run ledger with --merge flag, if you'd like to have a combined view of all accounts as a single ledger. For example:

sh
portfelj ledger --tax-year 2024 --merge

Convert to euro

By default, positions in ledger are displayed in the currency of trade.

Run ledger with --euro flag to automatically convert all prices to Euro:

sh
portfelj ledger --tax-year 2024 --euro

Get more help

Each sub-command has a built-in help. Just append --help to any command to view all available options:

sh
portfelj ledger --help