IbEstonia is a converter which takes trade data from Interactive Brokers as an input and creates a tax report which can be easily submitted to Estonian Tax and Customs Board.
It currently supports stocks, options & dividends. See Limitations section for known issues.
NB: This project currently is experimental. It is not meant for production use yet.
- Ruby 2.0+
- Node 8.0+
- Open Interactive Brokers Account Management
- Go to Performance & Reports -> Flex Queries
- Create a new Activity Flex Query:
- Query Name: ib-estonia-tax
- Select "Trades", include all fields from "Executions".
- Select "Cash Transactions", include all fields from "Dividends", "Withholding Tax" and "Detail".
- Select "Financial Instrument Information", include all fields.
- Save changes
- Run ib-estonia-tax query:
- Period: From the beginning of the year until the end of the year
- Run
- Execute and download all exports
- Rename ib-estonia-tax.xml to ib-$YEAR.xml
Make sure you generate these XML files for each year since your account inception.
Interactive Brokers flex queries do not provide ISIN numbers for all securities. These however are needed for the dividends report. Stocks & options report has a country field which is also inferred from ISIN number. If you don't care about these limitions (e.g. you fill them manually) then skip this part.
- Start your Trader Workstation
- Open Edit -> Global Configuration -> Api -> Settings
- Check "Enable ActiveX and Socket Clients" (feel free to keep it in Read-Only mode)
- Save
- Run
./start_isin_provider
Create a report using the confirmation data. For example, if you have data for 2015-2023 then run:
./start ib-2016.xml ib-2017.xml ib-2018.xml ib-2019.xml ib-2020.xml ib-2021.xml ib-2022.xml ib-2023.xml
- Long positions that have changed to a short position or vice versa are not displayed correctly (e.g. BUY 10 $RP, SELL 20 $RP). However closing a position and opening a new works correctly (e.g. BUY 10 $RP, SELL 10 $RP, SELL 10 $RP).
- Stock splits are not supported
- Option premiums are not included in the stock price
- Dividends: We use dividend report date for both report and tax withheld dates. This might not always be correct, but I haven't seen it on different dates yet.
- Unknown: fractional shares may not work
- Unknown: one company acquiring another for money may not work
- Unknown: one company acquiring another for shares may not work