Python Program for calculating Capital Gains Tax in UK
This repo is intended as a cleaner version the original, which seems to be outdated and messy.
Tool written in Python for calculating Capital Gains Tax on cryptocurrency disposals using UK tax rules.
The tool simply works out gains using the below strategy and does not work out your tax liability as this is related to your income, see https://www.gov.uk/capital-gains-tax/rates.
The easiest way to get started is by uploading your trades to https://cointracking.info/ and then downloading the trade list from https://cointracking.info/trade_prices.php
For general crypto-related tax questions see: https://bettingbitcoin.io/cryptocurrency-uk-tax-treatments/ or https://cryptotax.uk/
You use this code at your own discretion. We offer no guarantee that this will calculate tax as HMRC requires. A fundamental reason for adopting open source methods in this project is so that people from all backgrounds can contribute, spot errors and help improve the system.
This tool aims to follow the guidelines from HMRC on crypto taxes. Most of this has been based on the helpful sites https://bettingbitcoin.io/ and https://cryptotax.uk/ and some independent research looking at the HMRC internal manual for crytpocurrencies: https://www.gov.uk/hmrc-internal-manuals/capital-gains-manual/cg12100. The model so far works roughly as follows:
When an asset is disposed of the fee for the sale is subtracted from the proceeds.
Fees associated when buying assets with native currency are accounted for in the cost basis.
Note: cointracking may confuse which currency the fee was paid in and miscalculate the GBP value of the fee, so check your fee files to make sure you're not reporting any abnormally high fees.
There are various ambiguities around specifics of how gain should be calculated and we highlight them here. If you have any experience here or advice, please get in touch (https://www.reddit.com/user/uk-crypto-tax/).
The current model uses a FIFO strategy for the same day rule and the bread and breakfast rule stage. We are not sure however that this is strictly correct
The current model works out the gain on a trade as value_of_trade-cost_basis. However, how to calculate the value of a trade appears to be ambiguous. This can either be the value of the assets acquired or the value of the assets sold (in GBP). The current model uses "Counterpart" pricing for this valuation as this appears most intuitive, though there are different methods of doing this i.e. "Best" and "Transaction" prices. (The same issue may also apply to calculating the cost basis). The counterpart pricing (what we use) uses the value of the obtained assett.
We are unsure whether gifts of coins/coins gained from hard forks are taxable events with costbasis 0 or not. At the moment, the tool doesn't calculate this as a taxable event. WARNING: This can make big differences to overall calculated gain
Assets acquired during forks are treated as if the asset has been bought with 0 GBP.
There are basically four steps to getting this running:
Currently the program requires a csv file formatted in a specific way including all trades with GBP values --- see examples/sample-trade-list.csv. We used https://cointracking.info/ to obtain the necessary csv file and this is what we recommend at the moment. Go to https://cointracking.info/trade_prices.php and download the csv file from there (comma seperated!).
Similarly a list of fees can be downloaded from cointracking using a similar process.
The format changes from time to time so check that the columns are still the same.
Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a recent Python. Even some Windows computers (notably those from HP) now come with Python already installed.
For guidance installing python3 on your machine see https://wiki.python.org/moin/BeginnersGuide/Download
A config.json file is provided so the program can be edited easily.
Most important is to check the trade csv is named the same as your trade csv (as well as the fee list if you have one). Next change the tax year to calculate gains for the year you would like (2018 taxyear is 2017/18 taxyear and starts 06/04/2017).
The program will check for various abnormalities in the disposals (e.g. high fees, possible duplicate trades), check the console output to see these.
If you get any error messages when running the code and can't figure out what's going on, get in touch!
Donations are welcome to support us with improving the code and develop new features - see below!
We've set up addresses for most of your favourite coins ;)
ETH: 0xff2250aa872c77d2670af18c1d5081195ed499f8
Bitcoin: 19TB1Wz5JRVeLfD1KmP7zpyH9hK7S52UVK
BitcoinCash: 13fx3xWuff3Vt7GVZhqEPZaFeHetJLDjtT
DASH: XhN5yPWhfu5Q4Jwieip9xRVfNiWJWgEujK
LTC: LUSD4xWL2RgvCCUDtwhecm89BjuH4hPR1Q
ZCASH: t1V46YHSApsYod1U5jX5Szd8Zs5stkCxL1C
DOGE: DNnSJKMoTRSKw2iq52jRPt5pVh4LytWJoM
BAT: 0xff2250aa872c77d2670af18c1d5081195ed499f8
EOS: 0xff2250aa872c77d2670af18c1d5081195ed499f8
NANO (XRB): xrb_1rxyjpdo7wnbab813eisg1bdfaihzymod4tmuqafhch89j7heuapypyjj3sj
ETC: 0x5e7a73447cce4978c2a1fdde1b9c7e6e5dc84be8