OpenSteuerAuszug: generate your own eTax / eSteuerauszug for IBKR, Schwab and others

Yes, but only as a one-liner, for example for a depot of various stocks and savings accounts, just one line, total value on 31.12, total interest/div. paid in year with and without wht, 15% US etc.

It doesn’t fill out all individual stocks separately as if one would fill out declaration manually.

3 Likes

@j_from_b

I haven’t test it yet but taking a slightly to large range should work

This unfortunately is not possible, IBKR prevents it with this error message “Date range cannot exceed 365 days.” I have tried a curl with adjusting time range, that seems to work, but is not a nice solution at all. I have raised a ticket with their support. Also asked for an option “Last year” for the flex query export.

can you find some way to share your changes and/or example files?

The best example tax statements I have found in public so far are those:
DE: https://datalevel.ch/en/assets/downloads/dl-de_24.pdf
EN: https://datalevel.ch/en/assets/downloads/dl-en_24.pdf
They are pretty extensive, and it looks like they are generated using the official tax statement generator. You can easily extract the XML, and generate the PDF using your tool for comparison.

FWIW there are also projects on github that take the IBKR input and then drive the web UI using automated browsing to achieve this. (and LLMs are getting near the point where this does not need any specialized software at ALL)

Any links? This was my original idea. I guess with LLM computer use, it is possible to do with LLMs, but that is somewhat inefficient. I was thinking originally of using Playwright/debug interface or manipulating the webpage.

Yeah seems a lot less wasteful (and less risky) to have a deterministic program.

Can use the LLM to write the program

4 Likes

OK, I am ready to give it a try. To my shame I have to say that I did never use GitHub.

What I did so far: install pip. Didn’t work on linux mint, found some pointers to pipx and that apparently worked, “pipx install ibflex2”

Next I suppose I need to create a certain XML report in IBKR with Flex Query. The help in GitHub mentions “Reports > Flex Queries > Custom Flex Queries > Configure”, I only have “Activity” or “Trade Confirmation Flex Query”.

Does any kind soul have a sample what should be configured in the Flex Query? Or better still, a step by step instruction for a dummy like me?

Clone the repository

git clone GitHub - vroonhof/opensteuerauszug: Tool to generate swiss e-steuerauszug from banking exports

Navigate into the cloned directory

cd opensteuerauszug

— Virtual Environment Setup —

Create a virtual environment

python3 -m venv .venv

Activate the virtual environment

On macOS and Linux:

source .venv/bin/activate

On Windows (use this command instead):

.venv\Scripts\activate

pip install .[dev]

1 Like

Fwiw with uv/uvx no need to bother with virtualenv etc. (yeah I’m a huge fan)

2 Likes

Regarding Flex Query: There is detailed description. For my case, have selected all field for the specified key sections. It took me a some minutes to set it up, but once you have set it up, you can use it for any yearly exports.

There is also a general user guide for an overview. Overall, there is quite some docs, but needs some time to read. Some thing can probably be streamlined in the future a bit. If you feel like things could be written in a better way, just open an issue or pull request at GitHub. Or ask here in the forum.

1 Like

Thank you very much.

I got the Flex data as XML file.

The installation of pipx install ibflex2 did create directories .local/share/pipx and .local/share/venvs I think

Still need to download the Kursliste and probably import it into a database.

Thanks for your help. I have absolutely no experience with Python and I am not sure if the risk of running foreign programs on my Computer is worth the 30 CHF (I got it cheaper) that datalevel charges. I’ll use a dummy account with no access to nothing…

If you’re really paranoid, you can run everything in a container without access to your system or internet.

1 Like

Downloading the kursliste into the data/kursliste should do it for a one-off job. It takes a few minutes to extract data, but I assume this is fine.

I am not sure if the risk of running foreign programs on my Computer

All of this is open source on GitHub, if you are interested in details, you can check the code.

30 CHF (I got it cheaper) that datalevel

Is this a one-off fee, or a yearly one?

Anyways, in case of datalevel, you are giving them access (read-only I hope) to your IBKR account. In case of a data leak, it could at least be exposed that you are an IBKR customer.

I think it is up to everybody own decision what level of comfort and trust they chose. It is nice that we have this year at least 2 ways to import IBKR data via e-steuerauszug into tax return software while there used to be none such way for the past years.

If you decide to generate a report with opensteuerauszug and later on get the datalevel one, it would be very interesting if you could share the differences.

It is CHF 50 yearly, was an offer for 30 in December.

I’ll share here…

You don’t give them account credentials, there is some kind of read only access you can give them. So up to you what you trust and want to pay (or fix which you may not be able to with data level), but they can’t just separate you from your brokerage money.

Sorry, I did never ever in my life run a Python script. My system tells me that I need to use the command python3. So I do

python3 -m opensteuerauszug.steuerauszug ./ibkr_2025.xml --importer ibkr --tax-year 2025 -o output.pdf
/usr/bin/python3: Error while finding module specification for 'opensteuerauszug.steuerauszug' (ModuleNotFoundError: No module named 'opensteuerauszug')

Interesting: there is another error if I use a non-existent module:

python3 -m dummy ./ibkr_2025.xml --importer ibkr --tax-year 2025 -o output.pdf
/usr/bin/python3: No module named dummy

Also I wonder where I have to tell the script where the kursliste xml is…

Place the downloaded Kursliste XML file(s) into the data/kursliste/ directory within your OpenSteuerAuszug project

What is the OpenSteuerAuszug project, is that the current directory where the other files are? I’ll try. Did a find on my home but couldn’t find any directory named OpenSteuerAuszug…

I think I’m too old for learning all that configuration python GitHub project stuff.

I’ll probably just wait for the datalevel PDF…

Are you sure you are in the checkout directory of opensteuerauszug?

There you need to run the following commands first:

source .venv/bin/activate
pip install .[dev]

And then the command you posted.

Also I wonder where I have to tell the script where the kursliste xml is…

Download the file Course listings Initial V2.2 (35 MB): ICTax - Income & Capital Taxes

And place the XML file into data/kursliste of the checkout directory of opensteuerauszug (“OpenSteuerAuszug project” refers to the checkout directory of opensteuerauszug, most probably all lowercase).

Yes, for this IB is really professional. You can have account access roles which are different from account owner, beneficiary, etc.

Thanks.
What is the checkout directory of opensteuerauszug? I did a find and could not find any directory with that name.
Also pip did not work, I had to use pipx.

I did a find for “pip” with the following result:

Maybe ibflex2 is the directory I need? Tried your commands there, source worked but no success with install:

pipx install .[dev]
ERROR: Directory '/home/user/.local/share/pipx/venvs/ibflex2[dev]' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
Cannot determine package name from spec '/home/user/.local/share/pipx/venvs/ibflex2[dev]'. Check package spec for
errors.

Maybe some kind soul could give me a sequence of commands for linux that works…

You did a clone git clone from GitHub I assume (checking out the sources to your local compuer). Change into that folder (by default it is named opensteuerauszug). Run all the commands in that folder, no need to switch folders.

Also pip did not work, I had to use pipx.

Here I cannot help, for me, pip does work. I am not sure about the differences.

1 Like