A set of tools to semi-automatically deal with Polish TAX calculations involved in trading of crypto assets on bitbay.net.
For some reason nobody made it easy for a trader to correctly calculate taxes.
There are multiple issues:
- Export to CSV is limited only to three months
- Therefore, it is mostly useless, unless somebody periodically downloads it
- Also, it is in different format than the one displayed on the webpage
- Export via API is also limited
- Maybe it is possible to manually bootstrap the data and then create a cronjob to keep it updated?
- Nope, operations export is limited to just 200 entries, so it's possible to have a single transaction bigger than that...
- Maybe it is possible to manually bootstrap the data and then create a cronjob to keep it updated?
- Exported data does not contain an ID, and there are multiple transactions with the same datatime mark
- Assume that the given order is correct (avoid resorting)
- Export of transactions does not contain fees
- There is a separate operations page that contains fees
- But it's not trivial to connect them with relevant transactions
- But it is possible by grouping by date (up to few seconds) and sorting by value
- But it's not trivial to connect them with relevant transactions
- It is possible to download some invoices regarding fees, but those are incomplete and limited only to fees in PLN
- Some fees are taken in crypto
- There is a separate operations page that contains fees
All steps assume that we are in the cloned directory of this repository.
This step is required if we are interested in automatic creation of a Google Sheet containing calculated data.
- Create a new Sheet in Google Drive and copy ID from the URL (sample ID below)
- File -> Spreadsheets settings -> Locale United Kingdom (unofficial in PL but good looking combination of date and currency formatting)
- Go to: https://developers.google.com/sheets/api/quickstart/python
- Enable the Google Sheets API and download credentials.json file
python3 -m venv venv3
source venv3/bin/activate
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
- Create (or download from a safe storage) user_data directory, locate the last transaction
- Login to the web interface of (bitbay.net)
- Go to history -> operations -> fees
- Copy and paste all the new entries on top of: user_data/fees_history.txt
- (Recommended) Make screenshots of all the pages involved in user_data/scr/operations
- Go to history -> transactions
- Copy and paste all the new entries on top of: user_data/transactions_history.txt
- (Recommended) Make screenshots of all the pages involved in user_data/scr/transactions
- Execution example for sample_data directory
./bitbay_history_converter_txt_2_csv.py sample_data/fees_history.txt fees
./bitbay_history_converter_txt_2_csv.py sample_data/transactions_history.txt transactions
./bitbay_tax_calculator.py sample_data/transactions_history.csv sample_data/fees_history.csv --logfile update.log
./bitbay_gsheets_uploader.py sample_data/transactions_history_tax.csv sample_data/credentials.json 1KFsAUsowdp-S0iYv4nqHaj1_g68xpKwbIn6aba79tBg
- Copy user_data into a safe storage
- The code was created and tested on Linux Mint
- Python 3.6.7