eprbell / rp2

Privacy-focused, free, open-source cryptocurrency tax calculator for multiple countries: it handles multiple coins/exchanges and computes long/short-term capital gains, cost bases, in/out lot relationships/fractioning, and account balances. It supports FIFO, LIFO, HIFO and it outputs in form 8949 format. It has a programmable plugin architecture
https://pypi.org/project/rp2/
Apache License 2.0
256 stars 42 forks source link
8949 accounting altcoin bitcoin btc capital-gains coinbase cost-basis crypto cryptocurrency eth ethereum international nft nfts privacy tax tax-report taxes

RP2 Logo

RP2 v1.7.1

Privacy-focused, free, powerful crypto tax calculator

Static Analysis / Main Branch Documentation Check / Main Branch Unix Unit Tests / Main Branch Windows Unit Tests / Main Branch CodeQL/Main Branch

Tweet

Table of Contents

Introduction

RP2 is a privacy-focused, free, non-commercial, open-source, community-driven cryptocurrency tax calculator for multiple countries (currently US, Japan, Spain and Ireland are supported). Preparing crypto taxes can be a daunting and error-prone task, especially if multiple transactions, coins, exchanges and wallets are involved. This task could be delegated to a crypto tax preparation service, but many crypto users value their privacy and prefer not to send their transaction information to third parties unnecessarily. Additionally, many of these services cost money. RP2 solves all of these problems:

This means that with RP2 there are no transaction limits, no premium versions, no payment requests, no personal data sent to a server (at risk of being hacked), no account creation, no unauditable source code.

Another unique advantage of RP2 is transparent computation: RP2 generates full computation details for every lot fraction, so that it's possible to:

RP2 supports most countries and various accounting methods: supported accounting methods vary country by country.

RP2 reads a configuration file and an input spreadsheet containing crypto transactions. These input files can be generated either manually or automatically using DaLI, a RP2 data loader and input generator (which is also privacy-focused, free, non-commercial, open-source and community-driven). After parsing the input, RP2 uses high-precision math to calculate long/short term capital gains, cost bases, balances, average price, in/out lot relationships/fractions, and finally it generates output files.

RP2 has a programmable plugin architecture for output generators, accounting methods and countries. Built-in output generator plugins vary country by country, but RP2's architecture makes it possible to contribute additional generators for different countries or for different country-based cases.

RP2 has extensive unit test coverage to reduce the risk of regression.

IMPORTANT DISCLAIMERS:

How RP2 Operates

RP2 has been designed to have expressive primitives that can be used as building blocks for most tax scenarios: complex tax events can be described with patterns, built on top of these primitives (see the FAQ list for examples).

For the US case, RP2 treats virtual currency as property for tax purposes, as per IRS Virtual Currency Guidance.

RP2 supports various accounting methods (e.g. FIFO, LIFO, HIFO): however, in and out lots typically don't have matching amounts, so RP2 fractions them, maps in/out lot fractions and computes the resulting cost basis and capital gains for each lot fraction.

RP2 groups lot fractions into the following taxable event categories, each of which has a specific tax treatment:

For each of these categories RP2 generates an output spreadsheet with transaction details and computed gains/losses (see Input and Output Files for more details). Users can give this output to their tax preparer with the rest of their tax documentation (see also FAQ on which tax forms to file). Note that buying cryptocurrency using fiat currency is not a taxable event.

NOTE ON NFTs: Read the FAQ on NFTs to learn about how RP2 treats NFTs.

License

RP2 is released under the terms of Apache License Version 2.0. For more information see LICENSE or http://www.apache.org/licenses/LICENSE-2.0.

Download

The latest version of RP2 can be downloaded at: https://pypi.org/project/rp2/

Installation

RP2 has been tested on Ubuntu Linux, macOS and Windows 10 but it should work on all systems that have Python version 3.8.0 or greater.

Installation on Ubuntu Linux

Open a terminal window and enter the following commands:

sudo apt-get update
sudo apt-get install python3 python3-pip

Then install RP2:

pip install rp2

Installation on macOS

First make sure Homebrew is installed, then open a terminal window and enter the following commands:

brew update
brew install python3

Then install RP2:

pip install rp2

Installation on Windows 10

First make sure Python 3.8 or greater is installed (in the Python installer window be sure to click on "Add Python to PATH"), then open a PowerShell window and enter the following:

pip install rp2

Installation on Other Unix-like Systems

Then install RP2:

pip install rp2

Running

RP2 requires two files as input:

The two input files can either:

The formats of these files are described in detail in the Input Files section of the documentation.

Examples of an input spreadsheet and its respective config file:

After reading the input files, RP2 computes taxes and generates output files, which contain information on long/short capital gains, cost bases, balances, average price, in/out lot relationships and fractions, etc. They are described in detail in the Output Files section of the documentation.

To try RP2 with example files, download crypto_example.ods and crypto_example.ini. Let's call <download_directory> the location of the downloaded files.

The RP2 executable is country-dependent: rp2_<country_code>, where country code is a ISO 3166-1 alpha-2, 2-letter identifier (e.g. rp2_us, rp2_jp, etc).

To generate US tax output for the example files open a terminal window (or PowerShell if on Windows) and enter the following commands:

  cd <download_directory>
  rp2_us -m fifo -o output -p crypto_example_ crypto_example.ini crypto_example.ods

Results are generated in the output directory and logs are stored in the log directory.

The -m option is particularly important, because is selects the accounting method: rp2_us supports FIFO, LIFO and HIFO (if -m is not specified it defaults to FIFO).

To print full command usage information for the rp2_us command:

  rp2_us --help

Input and Output Files

Read the input files and output files documentation.

Supported Countries

Read the supported countries documentation.

RP2 Ecosystem

This is a call for coders: come and help us expand RP2's functionality!

RP2 is the first component of what could be a powerful, community-driven suite of open-source, crypto tax software. It is intended as the core of a larger project ecosystem, maintained by the community. These projects can extend RP2's capability, usefulness and ease of use in new ways. For example:

Important note: any RP2 ecosystem project must make user privacy its first priority.

If you'd like to start an ecosystem project, please open an issue to let the RP2 community know.

List of Ecosystem Projects

Here's the current list of projects in the RP2 ecosystem:

Reporting Bugs

Read the Contributing document.

Contributing

Read the Contributing document.

Developer Documentation

Read the developer documentation.

Frequently Asked Questions

Read the user FAQ list and the developer FAQ list.

Change Log

Read the Change Log document.