Crypto Tax Calculator
A tool to calculate the capital gains of cryptocurrency assets for Canadian taxes. The source data comes from a set of trade logs, which are provided by the exchanges. The adjusted cost base (ACB) is used to calculate the capital gains.
I created this software to calculate the capital gains from my 2017 cryptocurrency trades for tax purposes. For my 2018 taxes, I refined the software with many new options to handle missing logs, stolen assets, and other complex issues.
Please note that I am not an accountant, and I do not warrant the validity of the results.
The following exchanges are supported out-of-the-box:
It is easy to add support for additional exchanges.
Simply add a parser in
trade-parse-stream.js to convert a CSV row to the normalized format.
You can look at the existing parsers as examples of how to do this.
Run the program with
npm start or
--help option to see the available options.
Typical usage involves running the program with a set of trade logs in the form of CSV files. For example:
node index data/*-2018.csv -odata/results-2018.md --init=\BTC:0.73396222:12721.04,\ETH:4.18451232:3478.97,\LTC:11.09684:3113.88
The resulting Markdown or HTML contains:
- The assets carried forward from the previous year (if any).
- A list of trades, ordered by time, including fees and the running ACB.
- A list of dispositions, ordered by asset and time, including the POD, ACB, OAE, and the running gain (or loss).
- A summary of the aggregate dispositions per asset.
- A summary of the aggregate gain (or loss), ACB, and remaining balance per asset.
- The total taxable capital gains.
- The assets that can be carried forward to the next year (if any).
There are options for filtering by currency, defining the initial balance, limiting the number of trades, and providing historical data.
|Short option||Long option||Argument||Description|
||<spec> ||Only consider trades involving the specified assets.|
||Display this usage information and exit.|
||<spec> ||Define the initial balance and ACB of the assets.|
||Format the results as HTML instead of Markdown.|
||<file>||Write the results to the specified file.|
||Do not write the results.|
||<spec> ||Only show the specified assets.|
||<count>||Do not process more than the specified number of trades.|
||Write extra information to the console.|
||Request historical asset values from the internet.|
||<path> ||Read historical asset values from the specified directory.|
A subset of the available assets can be considered for the calculation by the
--assets option, or used to filter the results by the
The argument in both cases is a comma-separated list of assets.
The balances can be carried forward from last year by the
The argument is a comma-separated list of assets, each with its balance and adjusted cost base, in the form of
<asset>:<balance>[:<acb>],..., such as
Historical data may be provided to the program using the
The data for each currency pair must be stored in a JSON file named
Each JSON file must contain an array of historical samples, ordered by time.
Each historical sample must contain the following fields:
||Number||UNIX timestamp||The opening time of the trading period.|
||Number||Currency||The price at the opening of the trading period.|
||Number||Currency||The price at the closing of the trading period.|
Compatible files can be generated by the @davidosborn/crypto-history-parser npm package.