Programmatic Tax Return

Is there anyway of creating your own E-tax statement document with barcodes?

I traded 1500 different stocks last year on a US broker and there doesn’t seem to be any way of programmatically adding these trades to the tax return.

I was thinking about this. Since my canton converted to an online tax filing, it should be possible to either inject javascript or ‘drive’ the webpage using scripting or standard desktop automation.

I would contact the tax office and ask them how to proceed. Maybe they would accept for you to directly enter the totals from the bank statements?

Even if there is a difference, the overhead this would cause them to go through 1500 positions could exceed it and they may even prefer an alternate solution.

What if you fill the paper version? You can write a script that generates a PDF with all the info. I tried to do that a while ago. I think I got the official pdf from the canton and tried to fill it with python.

In the end, all they need to know is the value of your account on 31.12 and how much dividend you have received during the year. You can create a record for the whole portfolio and attach a statement with this information.

Things would get somewhat more complicated if you own shares of accumulating funds.

1 Like

Just put in the one-liner with

  • Total amount at end of the year
  • Dividends received through the year
  • Amount withheld on those dividends

And attach the exported PDF report from the broker.

I’m sure they’ll appreciate it too. :sweat_smile:


So you’re saying you do not have to indicate individual trades - even though they’re asking you for purchases and sales.

And then you just sign below “Ich bestätige die Richtigkeit und Vollständigkeit der in diesem Verzeichnis und Antrag gemachten Angaben”? :nerd_face:

If all the details are in the attached broker statement, there is nothing actually missing. It’s possible that some cantons/municipalities will get back to you and tell you that you have to manually fill out the form with all trades. However, I don’t see any real risk as you’re not hiding anything.


From my understanding, all these entries with transactions are actually supposed to be for your convenience… :face_with_monocle:

Agree with everything you wrote. It’s also what I’ve been doing with my IBKR statement.
That said, that’s the question: Are you “hiding” something when not providing transactions?

There is a company called Data Level. It seems they work with some brokers liek Saxo to offer a Swiss eTax statement service

I looked at their sample statement. I believe it’s possible for Interactive brokers to work with them but maybe they don’t care about Swiss investors.

I even thought it would be cool if one can create a script to convert IBKR statements into the Swiss eTax statement.

For my own tax return, I find it a bit complicated because I have US bonds and US ETFs plus broker interest. So I have to break them into two anyways as only ETFs need to be listed in DA-1.

If some programmers are up for it, this can be a nice community project :slight_smile:

1 Like

I actually tried to create one myself. Creating the XML is no problem, because everything is documented [1].

The problem is with creating the PDF, because most online tax portals only allow PDF uploads, at least for the canton I’m living in (eTax from Ringler Informatik AG) . And exactly that information, meaning the tool being used to generate it, is not public. I asked the people that are responsible for the standard [2], but they told me they only give out that information to cantons and banks… could have otherwise been a cool project.

[1] eCH-0196 E-Steuerauszug V2.2.0 | eCH E-Government Standards
[2] eSteuerauszug - Schweizerische Steuerkonferenz SSK

1 Like

Thanks for checking, this would have been interesting. That said, as the eSteuerauszug is used as alternative to a regular broker statement, it’s used as documentation/evidence from the broker (especially important when declaring withholding taxes), so I suspect that even if that tool was available to anyone, they wouldn’t accept unofficial PDFs.

An interesting compromise would be for tax software to allow importing the (unofficial) XML file while still attaching a regular broker statement as proof. I don’t expect that to happen, though, it’s presumably too niche.

1 Like

How about you stop trading 1’500 stocks a year? Reason beeing that such volume may indeed put you into the professional trader bucket (if you were successful in generating a profit). Second reason is that you should probably somewhen have a look at the anonymous trading addicts group… You may find them here: Anonymous Trading Addicts Group - Swiss Chapter

It’s algorithmic through Alpaca, thus it was set and forget with the occasional error handling.

The returns were good last year, but this was probably just due to favourable market conditions across the board.

I’m happy to pay a high tax on the returns if it would make the tax documentation a non issue.

Hmmm… to be honest. Sounds like you programmed a trading system that you then implemented through an API Broker. This sounds like probably the first case of professional trading I see on this board.

Given you coded things, I trust you had all the log files and transactions so that you couldn yourself generate a P&L. If I was in your shoes - I would create a simple summary of:

  • Money Invested on 01.01
  • Additional Moneys added to the Portfolio since
  • Realized Capital Gains(Gross)
  • Trading Cost
  • Withholding Tax incurred (non-recoverable only)
  • Money Invested on 31.13
  • number of Transactions

Based on this, I would create a simple three liner where you als the tax Authorities to conclude if you were a professional investor and shall create a P&L and Balance Sheet, or if they simply recognize this summary to suffice for a provate investor and lump-sum declaration…


Hi @TeaGhost,

Thank you for your reply.

Yes, I have all of the account’s activity in key-value databases, and I have the ability to chop it up and present it in any way that is required. I also believe that the effort to do so is not unreasonable.

Thank you for your list of what to include in the summary; I was considering doing something similar, and this gives me a better idea of what to expect.

I am not sure why being designated as a professional investor would be an issue. Except for the obvious tax implications, this should not exceed 35%? Other benefits include the ability to write off losses and operating costs, though these do not account for 35% of profits. Is there another mountain of tax forms that come with being a professional investor?

I guess all your capital gains are taxed as income compared to no capital gains taxes at all as a private investor. If you live in ZG/SZ I guess it’s bearable but in high tax cantons this is going to hurt.

Depending on canton and taxable income, marginal tax rates can be up to 42%, if I remember correctly. You’d have to check for your canton/municipality and taxable income to estimate this.

As I understand it, you’d be considered self-employed, which means you’d also have to pay social security on your net profits (about 10%, at least that would be tax-deductible as well).

I’d assume tax status does not automatically transfer to social security status.