Giter VIP home page Giter VIP logo

cryptotax's Introduction

CryptoTax

A set of classes for calculating cryptocurrency tax (US)

About

The goal of this project is to be able to calculate capital gain tax for each individual cryptocurrency trade. For that purpose, we load initial balances, add all the trades and then execute those in chornological order to figure out the cost-basis for each trade.

Exchanges

Where possible, we try to utilize the exchange API to retrieve the trades. Some exchanges make this difficult by providing incomplete list of trades (Bittrex) or requiring the trade-pair symbol (Binance), so in those cases we parse CSV files instead, which typically contain all the information.

How to use

The index.php shows an example usage and renders a basic dashboard. Our main class is the CryptoTax class which collects balances and trades and then calculates the cost basis for reach trade (called deltas here).

Each supported exchange has its own class under /Exchanges, and follows a similmar approach with the goal of obtaining a normalized array of trades. The exception is Coinbase, which is used to initialize the balances instead.

The method of operation is retrieving the trades array from each exchange, and then loading it up using the addTrades() method on the CryptoTax instance.

You can add individual balances and trades using the addBalance() and addTrade() respectively. See usage instructions in the class' documentation.

You can also pick between two common methods for calculating cost-basis - FIFO (First-in / First out) and LIFO (Last-in / First-out). You should consult with your CPA / Tax lawyer regarding the method to use in your case.

After calculating the cost-basis using calculateDeltas(), you can also retrieve unresolved trades using getUnresolved() - those are trades that did not have available balance left to calculate the cost-basis from. If you manually add the balance with the original price, you should be able to resolve all of the trades.

cryptotax's People

Contributors

erangalp avatar

Stargazers

 avatar  avatar Brett Brewer avatar daffoxdev avatar  avatar Carl Price avatar Wikalp avatar Troy Therrien avatar ₴Ⱡ33₱ avatar  avatar Tadej Magajna avatar

Watchers

James Cloos avatar

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.