rp2 1.0.5


Privacy-focused, free, open-source cryptocurrency US tax calculator: 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 and LIFO, it features transparent computation for easy result verification, and it generates data that tax accountants can understand, even if they are not cryptocurrency experts (e.g.form 8949). Project…

Privacy-focused, free, open-source cryptocurrency US tax calculator: 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 and LIFO, it features transparent computation for easy result verification, and it generates data that tax accountants can understand, even if they are not cryptocurrency experts (e.g.form 8949).

Project description

RP2 v1.0.5

Table of Contents

– Introduction

– License

– Download

– Installation

– Running

– Input and Output Files

– RP2 Ecosystem

– Reporting Bugs

– Contributing

– Developer Documentation

– Frequently Asked Questions

– Change Log


RP2 is a privacy-focused, free, open-source US cryptocurrency tax calculator.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:

– it manages the complexity related to coin flows and tax calculation and it generates data that accountants can understand (in the format of form 8949), even if they are not cryptocurrency experts;

– it prioritizes user privacy by storing crypto transactions and tax results on the user’s computer and not sending them anywhere else;

– it’s free and open-source.

Another unique advantage of RP2 is transparent computation: it generates full computation details for every lot fraction, so that it’s possible to verify step-by-step how RP2 reaches the final result.

RP2 supports the FIFO and LIFO accounting methods, to help minimize the amount due.

It reads in a spreadsheet containing crypto transactions.The spreadsheet can be generated either manually or automatically using DaLI, a RP2 data loader and input generator (which is also privacy-focused, free and open-source).

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 spreadsheets.

RP2 has a programmable plugin architecture for output generators, accounting methods and countries.The output generator builtin plugins are US-specific, but RP2’s architecture makes it possible to contribute additional generators for different countries or for different US-based cases.

The builtin generator plugins are:

– tax_report_us: generates a tax report meant to be read by tax preparers (in the format of form 8949);

– rp2_full_report: generates a comprehensive report, with complete transaction history, lot relationships/fractions and computation details;

– open_positions: geterates a report on assets with non-zero crypto balance: unrealized gains / losses, portfolio weighting, and more.

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


– RP2 offers no guarantee of correctness (read the license): always verify results with the help of a tax professional.

– The author of RP2 is not a tax professional, but has used RP2 personally for a few years.

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 using these primitives (see the FAQ list for examples).

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

RP2 supports the FIFO and LIFO accounting methods: 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:

– AIRDROP: gains from airdrops;

– DONATE: donations to charitable organizations;

– FEE: fee-only transaction, used in some DeFi scenarios (e.g.gas fee for running certain smart contracts);

– GIFT: gifts to parties who are not charitable organizations (not tax-deductible).

– HARDFORK: gains from hard forks;

– INCOME: gains from miscellaneous income (e.g.Coinbase Earn);

– INTEREST: gains from interest;

– MINING: gains from mining;

– MOVE: the fee for moving currency between two accounts controlled by the same owner;

– SELL: specifically, sale and exchange of one cryptocurrency for another.RP2 splits them in two subcategories:long-term capital gains, if the lot was held for more than 1 year, orshort-term capital gains otherwise;

– STAKING: gains from staking;

– WAGES: income from crypto wages.

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.


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.


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


RP2 has been tested on Ubuntu Linux, macOS and Windows 10 but it should work on all systems that have Python version 3.7.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.7 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

– install python 3.7 or greater

– install pip3

pip install rp2


RP2 requires two files as input:

– an ODS-format spreadsheet, containing crypto transactions (ODS-format files can be opened and edited with LibreOffice and many other spreadsheet applications);

– a JSON config file, describing the format of the spreadsheet file: what value each column corresponds to (e.g.timestamp, amount, exchange, fee, etc.) and which cryptocurrencies and exchanges to expect.

The two input files can either:

– be generated automatically using DaLI, the data loader and input generator for RP2, or

– be prepared manually by the user.

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:

– input/crypto_example.ods

– config/crypto_example.config (if desired, this config file can be used as boilerplate).

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.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.config.Let’s call

the location of the downloaded files.

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

cd rp2_us -m fifo -o output -p crypto_example_ crypto_example.config crypto_example.ods

Results are generated in the

output directory and logs are stored in the



-m option is particularly important, because is selects the accounting method: RP2 supports FIFO and LIFO (if

-mis 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.

RP2 Ecosystem

This is a call for projects: 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:

– DaLI data loader plugins: add support for more exchanges and wallets (via REST API and/or CSV files).Dali, the RP2 data loader, uses them to generate an input ODS file and a config file that can be fed directly to RP2;

– RP2 plugins: RP2 can be expanded via its programmable plugin architecture, which enables support for new output generators, countries and accounting methods;

– RP2 GUI: make RP2 more user-friendly and accessible to people who are not familiar with the CLI;

– RP2 high-level interface: RP2 captures complex tax events using a few powerful, low-level primitives, aggregated in patterns.

A higher level tool, might abstract out these patterns and present them to the user in a friendlier way (for example it may capture a complex concept like DeFi bridging as a primitive, rather than a pattern);

– more…

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:

– DaLI: data loader and input generator for RP2 https://github.com/eprbell/rp2.

Reporting Bugs

Read the Contributing document.


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.

RP2 Change Log


– added country plugin for Japan

– small improvements in documentation


– fixed issue #39: if ODS file had numeric unique_id it tripped the type checking system

– added support for generators section in configuration: this allows users to select which generator plugins to run.Also deprecated -l/–plugin CLI options

– updated documentation with new generators section description

– added FAQ


– minor improvements


– new open positions plugin, showing a variety of information on unrealized gains and losses https://github.com/eprbell/rp2/pull/35

– minor improvements to documentation


– Tax season is over: time for RP2 to hit v1.0.0! RP2 (and DaLI) gained a lot of users and traction in less than one year of existence https://star-history.com/#eprbell/rp2&Date.During this time lots of bugs were fixed and features added.Thanks to everybody who engaged with PRs, issues, discussions and DMs.


– fixed a bug in rp2_full_report generator reported in #31: in out-transactions if crypto_fee == 0 and fiat_fee > 0, the fiat fee was reported as zero (but this affected only the output, not the tax calculation which was correct)

– added some user FAQs


– minor improvements to documentation


– various improvements to documentation


– RP2 logo worked on Github, but not on Pypi: fixed


– added RP2 logo to readme.md

– improved an error message when disposed-of crypto is greater than acquired crypto


– removed requirements.txt: now using dev section in setup.cfg, which avoids duplication of information

– added FAQ on Excel being unable to open some RP2-generated ODS files


– added initial version of developer FAQ document: https://github.com/eprbell/rp2/blob/main/docs/developer_faq.md

– minor refactoring edits


– added crypto_fee to InTransactions (by popular demand): previously in-transaction fee would only accept fees in fiat, but in certain situations fee is paid in crypto (e.g.crypto conversion, etc.).With this fix, either crypto_fee or fiat fee can be assigned (not both).If fiat_fee is assigned, crypto_fee is set to 0.If crypto_fee is assigned, fiat_fee is set to crypto_fee * spot_price.

The reason for this behavior is that if the fee is paid in fiat, then no crypto is used for the fee, but if the fee is paid in crypto, then its converted fiat value is needed to compute taxes.Note that RP2 models a non-zero crypto_fee with a separate fee-typed out-transaction.

– added new unit test for the new InTransaction crypto_fee (input/test_data4.ods)

– updated documentation to reflect new features from this release

– added a new FAQ on crypto rewards and reworded various answers.


– added fee-only transactions: this type of transactions occur in certain DeFi scenarios (see relevant FAQ for more)

– added documentation of transparent computation, including one new FAQ on how to verify RP2 tax computation results: https://github.com/eprbell/rp2/blob/main/docs/user_faq.md#how-to-verify-that-tax-computation-is-correct

– minor edits to documentation


– added new FAQs

– added pointers in documentation to DaLI, the data loader and input generator for RP2: https://github.com/eprbell/dali-rp2


– improved error message when ods_parser._process_constructor_argument_pack tries to parse a numeric argument and fails because the value is not numeric


– added an extra check in IntraTransaction constructor: if spot_price == 0 and fee > 0 then raise an error (because the fiat value of the fee cannot be computed)

– minor edits to documentation


– in the tax_report_us output the following tabs had the description field mistakenly hidden: Airdrops, Income, Interest, Mining, Staking, Wages.All other tabs didn’t have the problem.The hidden field is now visible

– the unique_id field (containing hash or exchange-specific id) is now generated in the output files (both tax_report_us and rp2_full_report)


– added Income sheet to plugin ODS template (needed by tax_report_us generator to support the new Income InTransaction type)


– added support for Income-type InTransaction (to capture misc income like Coinbase Earn)

– renamed old unique_id field to internal_id and added a new unique_id field to all transactions, which captures hash for IntraTransactions and exchange-specific unique ids for In/OutTransactions

– updated documentation to reflect latest changes

– minor fixes and refactoring


– Add py.typed to rp2 package to indicate type hint support.


– Added support for multiple logger names (e.g.

plugins can use different logger names than core RP2 code).


– refactored to_string() method to be top-level, so that it’s easier to use in external projects.

– added RP2 Ecosystem paragraph to README.md

– added a few more FAQs to user frequently asked questions document

– improved CLI description

– minor fixes


– fixed issue #6: OUT transaction fee is now a deduction as per https://www.irs.gov/publications/p544 and https://taxbit.com/cryptocurrency-tax-guide (previously it was considered part of proceeds and therefore taxed)

– restructured User FAQ document

– added several questions to User FAQ document (many of them DeFi-related)

– various edits and improvements throughout entire documentation


– add DONATE and GIFT-typed InTransactions

– changed Legend sheet to include time filter information

– updated documentation to reflect changes in this version


– added hyperlinks to rp2_full_report output:taxable events and acquired lots in tax sheet are now hyperlinked to their definition line in the in-out sheet.In LibreOffice, CTRL-click on them to jump to the target (on Mac Command-click)summary lines in the Summary sheet are now hyperlinked to the first line of the given year in the tax sheet

– modified time filter CLI options (-f and -t) to accept a full date (YYYY-MM-DD): so it’s now possible to filter transactions before and after a given day

– major refactoring: renamed “from lot” and “in lot” to “acquired lot” throughout identifiers, strings, templates, documentation, etc.

– updated documentation to reflect changes in this version


– added profiler instrumentation

– added large input test and refactored ODS output test

– removed rmtree(“output”) from test_ods_output_diff.py: it modifies the file system, which can cause problems when running tests in parallel (currently not enabled, but that may change in the future).

– minor fixes


– fixed a bug in timestamp check: in and out lots were not allowed to have the same timestamp, but in certain scenarios it could happen (e.g.high-frequency trading)

– fixed a subtle corner-case bug in LIFO, which caused the first gain/loss pair to be incorrect: the minimal input that reproduced the bug is now captured in one of the tests (test_data2.ods, sheet B1).This ensures there will not be a regression.

– disable a link check in user faq: the link was failing the check (incorrectly) on Github actions


– added new LIFO tests

– minor fixes


– added accounting-method programmable plugin infrastructure: by subclassing AbstractAccountingMethod it’s now possible to add support for a new accounting method (previously only FIFO was hard-coded in)

– added accounting-method plugins: FIFO, LIFO

– added accounting-method-specific tests, plus additional tests of internal classes (both new and old)

– Added Legend sheet to tax_report_us output

– updated documentation to reflect changes in this version

– minor fixes


– added country-specific programmable plugin infrastructure: by subclassing AbstractCountry it’s now possible to add support for a new country (currently only US is supported)

– abstracted out currency from APIs and code in general: references to “usd” have been changed to “fiat”

– updated documentation to reflect changes in this version


– Verified software is up to date for FY 2021

– Wrote several answers in User FAQ document

– Minor fixes


– Added several new tests (from/to_year command line option variations and new transaction types)

– Reworked time filter logic to fix two bugs related to -f and -t options:with time filtering on, running sums reflected only filtered transactions, instead of all transactions (in other words, running sums should not be affected by filtering)with time filtering on, number of fractions reflected also fractions with year higher than time filterwith time filtering on, sold lot percentages would be shown incorrectly in some cases

– Updated documentation: various fixes and improvements


– added new transaction types: AIRDROP, HARDFORK, INTEREST, MINING, STAKING, WAGES.

Removed transaction type EARN, which used to encompass all the above types

– revisited output generators: rp2_report was renamed to rp2_full_report and mock_8949_us was renamed to tax_report_us.The tax_report_us plugin now generates one sheet per taxable event type: Airdrops, Capital Gains, Donations, Gifts, Hard Forks, Interest, Investment Expense, Mining, Staking, Wages.

– fixed bug in from/to_year logic: entry sets didn’t consider the time filter in certain corner cases

– updated documentation to reflect above changes


– Added from/to_year command line option


– Minor fixes related to Pypi package distribution and upload


– Minor fixes related to Pypi package distribution and upload


– First version uploaded to Pypi

– Added pre-commit hooks

– Added bandit security checks

– Major revision of user and developer documentation

– Fixed lint errors

– Various bug fixes and improvements


– First version tracked in change log

– Added Python packaging support

– Switched to high-precision math (decimal.Decimal)

– Finished documentation (except FAQs)

– Added bumpversion

– Various bug fixes and improvements

Project details

Release history Release notifications | RSS feed








































Download files

Source Distribution

Built Distribution

Hashes for rp2-1.0.5.tar.gz

|Algorithm||Hash digest|




Hashes for rp2-1.0.5-py3-none-any.whl

|Algorithm||Hash digest|




Leave a Reply

Next Post

Crypto Market Daily Highlights – ETH Bucks Trend in Bullish Session

Key Insights: - On Tuesday, the crypto top ten were on the move again, with Cardano (ADA) taking over as the front runner.- A choppy start to the session saw the crypto market hit reverse before recovering, with the NASDAQ 100 delivering a US session boost.- The total crypto market cap followed Monday’s $82.59 billion…
Crypto Market Daily Highlights – ETH Bucks Trend in Bullish Session

Subscribe US Now