Code Monkey home page Code Monkey logo

crypto-tax-calculator's Introduction

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.

Introduction

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.

Exchanges

The following exchanges are supported out-of-the-box:

  • Binance
  • Bittrex
  • Kraken
  • KuCoin

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.

Usage

Run the program with npm start or node index. Add the --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).

Options

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
-a --assets <spec> [1] Only consider trades involving the specified assets.
-h --help Display this usage information and exit.
-i --init <spec> [2] Define the initial balance and ACB of the assets.
-m --html Format the results as HTML instead of Markdown.
-o --output <file> Write the results to the specified file.
-q --quiet Do not write the results.
-s --show <spec> [1] Only show the specified assets.
-t --take <count> Do not process more than the specified number of trades.
-v --verbose Write extra information to the console.
-w --web Request historical asset values from the internet.
-y --history <path> [3] Read historical asset values from the specified directory.

[1] A subset of the available assets can be considered for the calculation by the --assets option, or used to filter the results by the --show option. The argument in both cases is a comma-separated list of assets.

[2] The balances can be carried forward from last year by the --init option. 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 --init=BTC:1:5000,ETH:5:1000,LTC:10:80.

Historical data

[3] Historical data may be provided to the program using the --history option.

Format

The data for each currency pair must be stored in a JSON file named <base>-<quote>.json. Each JSON file must contain an array of historical samples, ordered by time. Each historical sample must contain the following fields:

Field Type Semantics Description
time Number UNIX timestamp The opening time of the trading period.
open Number Currency The price at the opening of the trading period.
close Number Currency The price at the closing of the trading period.

Compatible files can be generated by the @davidosborn/crypto-history-parser npm package.

crypto-tax-calculator's People

Contributors

davidosborn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

crypto-tax-calculator's Issues

Couldn't find intersection babe lerror

Hello,

I am getting this error when I try to run npm run build.
image

I also get this error when i try to run npm start
image
(seems like a similar error)

any idea how to fix this? I am not very familiar with babel and how it works.

Thanks!

Latest results do not match previous results

When I ran the software recently, it produced a different result than it did months ago on the same set of input files. This indicates there may be something wrong with the software, or the input files. I am investigating...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.