It is fairly easy to start trading stocks in Revolut. Processing monthly statements in pdf format from trading is not fun at all.
Insurrector is a project that makes it easier to process Revolut statement documents and produces files in a format that can be used by spreadsheet programs to make further calculations for tax returns.
Project provides two interfaces:
- command line interface (CLI)
- graphical user interface (GUI)
Project is from large part based on Revolut Stocks calculator for Bulgarian National Revenue Agency by Doino Gretchenliev. If you find this useful, navigate to his project page and consider a support.
Please beware that you should double check output of the tooling. There are quite a few places where the results could be off. That includes parser or bug in a code that hasn't been tested very well.
- The tool recursively scans the input directory for statement files(
*.pdf
). - The statement files are then being parsed to extract all activity information.
- The calculator then obtains the last published exchange rate (USD to CZK) for the day of each trade.
- During the last step all activities are processed to produce the required data.
- The calculator parses exported statements in
pdf
format. Parsing apdf
file is a risky task and heavily depends on the structure of the file. In order to prevent miscalculations, please review the generatedstatements.csv
file under theoutput
directory and make sure all activities are correctly extracted from your statement files. - Revolut doesn't provide information about which exact stock asset is being
sold during a sale. As currently indicated at the end of each statement
file, the default tax lot disposition method is
First-In, First-Out
. The tool is developed according to that rule. - The trade date (instead of the settlement date) is used for any calculation.
- By default the tool uses locally cached exchange rates located here. It is also possible to automatically download exchange rates provided Czech Central Bank (CNB).
- Python version >= 3.7
- Linux
$ pip install .
$ insurrector-cli --help
$ insurrector-cli -i <path_to_input_dir> -o <path_to_output_dir>
Output:
[INFO]: Collecting statement files.
[INFO]: Collected statement files for processing: ['input/statement-3cbc62e0-2e0c-44a4-ae0c-8daa4b7c41bc.pdf', 'input/statement-19ed667d-ba66-4527-aa7a-3a88e9e4d613.pdf'].
[INFO]: Parsing statement files.
[INFO]: Generating [statements.csv] file.
GUI is based on Qt5 and might require some additional libraries installed.
$ pip install '.[gui]'
$ insurrector-gui
Errors are being reported along with an ERROR
label.
The error indicates that there was an issue obtaining the exchange rate from CNB online service. Navigate to CNB online service, select all months, year, currency: USD, and output format: text. If that works, you can report an issue.
There was an issue finding input statement files. Please, check your input directory configuration and file permissions.
The calculator parser was unable to parse any activities within your statement file. Please, check your statement files and ensure there are reported activities. If there are reported activities, but the error still persists, please open an issue.
The calculator found unsupported activity type/s. Please, open an issue and include the reported activity type.
The calculator, while trying to perform the SSP surrender shares operation, was unable to find the previously purchased shares for the same stock symbol. Please, ensure there is a statement file in the input directory, containing the original purchase.
File format: .pdf
That's the default parser and handler statement files downloaded from Revolut app.
File format: .csv
A generic parser for statements in CSV format. The parser could be used with structured data, that could be easily organized to fit the parser's requirements.
In order for the file to be correctly parsed the following requirements should be met:
- The following columns should be presented:
trade_date
: The column should contain the date of the trade in dd.MM.YYYY format.activity_type
: The current row activity type. The following types are supported: ["SELL", "BUY", "DIV", "DIVNRA", "SSP", "MAS"]company
: The name of the stock company. For example Apple INC.symbol
: The symbol of the stock. For example AAPL.quantity
: The quantity of the activity. In order to correctly recognize surrender from addition SSP and MAS activities, the quantity should be positive or negative. For all other activity types, there is no such requirement(it could be an absolute value).price
: The activity price per share.amount
: The total amount of the activity. It should be a result of (quantity x price) + commissions + taxes.
- The first row should contain headers, indicating the column name, according to the mapping above. There is no requirement for columns to be presented in any particular order.
- The activities, listed in the file/s should be sorted from the earliest trading date to the latest one. The earliest date should be located at the very begging of the file. When you're processing multiple statement files you can append them together(no need to merge the activities).
- DIVNRA, which represents the tax that was paid upon receiving dividends, should follow DIV activity. Other activities could be listed between those two events. DIVNRA is not required for all DIVs but would trigger calculations for dividend tax owed to NAP. DIV activity amount should be equal to dividend value + tax.
In order to verify the parser correctness, you can compare the generated
statements.csv
file with your input file. The data should be the same in both
files.
This was created as a simple fork of Revolut Stocks calculator for Bulgarian National Revenue Agency by Doino Gretchenliev to prepare tax return in Czechia. Since then I have moved away from Revolut. I don't have intention to improve this.
If you find this useful, navigate to Doino's project page and consider to support him.