Learn R Programming

cryptoTax: Crypto taxes in R (Canada only)

Disclaimer: This is not financial advice. Use at your own risks. There are no guarantees whatsoever in relation to the use of this package. Please consult a tax professional as necessary.


Helps calculate crypto taxes in R.

  1. First, by allowing you to format .CSV files from various exchanges to one large dataframe of organized transactions.
  2. Second, by allowing you to calculate your Adjusted Cost Base (ACB), ACB per share, and realized and unrealized capital gains/losses.
  3. Third, by calculating revenues gained from staking, interest, airdrops, etc.
  4. Fourth, by calculating superficial losses as well, if desired.

This is a work in progress. If you notice bugs, please report them: https://github.com/cryptoltruist/cryptoTax/issues.

Why use cryptoTax?

What are the benefits of using an R package to do your crypto taxes as opposed to an online commercial software?

  1. Full transparency on algorithms (open code)
  2. You stay in control of your data (no need to upload it on another platform)
  3. You can reuse your script (no need to start from scratch every year)
  4. No limit on the number of transactions
  5. Easy to automatically recategorize transactions as desired
  6. Unlimited flexibility thanks to the power of R
  7. The community can contribute for continuous improvement and feature requests
  8. Easy to export a csv or excel file from all formatted transactions
  9. It is free

Installation

To install, use:

remotes::install_github("cryptoltruist/cryptoTax")

ACB demo

library(cryptoTax)
data <- data_adjustedcostbase1
data
datetransactionquantitypricefees
2014-03-03buy1005010
2014-05-01sell5012010
2014-07-18buy5013010
2014-09-25sell409010
ACB(data, spot.rate = "price", sup.loss = FALSE)
datetransactionquantitypricefeestotal.pricetotal.quantityACBACB.sharegains
2014-03-03buy10050105000100501050.10NA
2014-05-01sell5012010600050250550.103485
2014-07-18buy50130106500100901590.15NA
2014-09-25sell409010360060540990.15-16

For more on calculating the ACB, as well as superficial losses, see the corresponding vignette.

Supported exchanges

Currently, the following exchanges are supported with the format_* (or format_detect()) functions:

  1. Adalite
  2. Binance
  3. BlockFi
  4. Crypto.com (app, exchange, wallet)
  5. Celsius
  6. CoinSmart
  7. Exodus wallet
  8. Gemini
  9. Newton
  10. Pooltool (ADA)
  11. Presearch
  12. Shakepay
  13. Uphold

To support another exchange not listed here, please open an issue. You can also prepare your own file according to the style of one of those exchanges and use the corresponding function.

Workflow demo

# Prepare list of coins
my.coins <- c("BTC", "CRO", "ETH", "ETHW")
list.prices <- prepare_list_prices(coins = my.coins, start.date = "2021-01-01")
#> ❯ Scraping historical crypto data
#> ❯ Processing historical crypto data
# Note that for some exchanges this step may be unnecessary

# Load data and format shakepay file
data(data_shakepay)
formatted.shakepay <- format_shakepay(data_shakepay)

# Load data and format CDC file
data(data_CDC)
formatted.CDC <- format_CDC(data_CDC)

# Merge data from the different exchanges
all.data <- merge_exchanges(formatted.shakepay, formatted.CDC)

# Format data with ACB
formatted.ACB <- format_ACB(all.data)
#> Process started at 2023-02-10 17:20:47. Please be patient as the transactions process.
#> [Formatting ACB (progress bar repeats for each coin)...]
#> Process ended at 2023-02-10 17:20:49. Total time elapsed: 0.02 minutes

# Let's get a preview of the output
as.data.frame(formatted.ACB[c(1, 4, 8, 10, 19, 20), c(1:6, 7:14, 24:26)])
datecurrencyquantitytotal.pricespot.ratetransactionfeesdescriptioncommentrevenue.typevalueexchangerate.sourcecurrency2gainsACBACB.share
2021-05-03 22:05:50BTC0.000733451.2569882.7777778buy0crypto_purchaseBuy BTCNA51.25000CDCexchangeBTCNA51.250069882.7777778
2021-05-07 23:06:50ETH0.020592054.212632.5750000buy0crypto_purchaseBuy ETHNA54.21000CDCexchangeETHNA54.21002632.5750000
2021-05-21 12:47:14BTC0.00013000.0056527.6188000revenue0shakingsatscreditairdrops7.34859shakepayexchangeBTCNA104.283348886.0827905
2021-05-29 23:10:59CRO6.40395450.000.1764535revenue0referral_card_cashbackCard Cashbackrebates1.13000CDCexchangeCRONA53.42000.1741274
2021-06-27 21:17:50ETH0.00076333.124087.6923838revenue0crypto_earn_interest_paidCrypto Earninterests3.12000CDCexchangeETHNA57.38002685.1921836
2021-07-06 22:18:40CRO0.32079920.260.8104758revenue0crypto_earn_extra_interest_paidCrypto Earn (Extra)interests0.26000CDCexchangeCRONA53.68000.1083560

Summary info

# Get latest ACB.share for each coin (ACB)
report_overview(formatted.ACB,
  today.data = TRUE, tax.year = "2021",
  local.timezone = "America/Toronto",
  list.prices = list.prices
)
#> gains, losses, and net have been filtered for tax year 2021
date.lastcurrencytotal.quantitycost.sharetotal.costgainslossesnetrate.todayvalue.todayunrealized.gainsunrealized.lossesunrealized.netcurrency2
2021-07-23 17:21:19CRO535.04063560.1160.660.0000.000.1157.82NA-2.84-2.84CRO
2021-07-25 18:22:02BTC0.001361243035.5558.5820.57020.5730099.5940.97NA-17.61-17.61BTC
2021-07-28 23:23:04ETH0.01140542685.1930.638.2508.252149.9524.52NA-6.11-6.11ETH
2021-07-11 20:19:55ETHW0.35580678.993.200.0000.005.291.88NA-1.32-1.32ETHW
2021-07-28 23:23:04TotalNANA153.0728.82028.82NA125.190-27.88-27.88Total

# Get summary of realized capital gains and losses
report_summary(formatted.ACB,
  today.data = TRUE, tax.year = "2021",
  local.timezone = "America/Toronto",
  list.prices = list.prices
)
#> gains, losses, and net have been filtered for tax year 2021 (time zone = America/Toronto)
TypeAmountcurrency
tax.year2021CAD
gains28.81CAD
losses0.00CAD
net28.81CAD
total.cost153.07CAD
value.today125.19CAD
unrealized.gains0.00CAD
unrealized.losses-27.88CAD
unrealized.net-27.88CAD
percentage.up-18.21%CAD
all.time.up0.61%CAD

Revenue estimation

table.revenues <- report_revenues(formatted.ACB, tax.year = "2021")
#> Note: revenues have been filtered for tax year 2021
table.revenues
exchangedate.lasttotal.revenuesairdropsreferralsstakingpromosinterestsrebatesrewardsforksminingcurrency
CDC2021-07-23 17:21:1996.150.0030.190010.3651.151.23.20CAD
shakepay2021-06-23 12:21:4966.2836.2830.00000.000.000.00.00CAD
total2021-07-23 17:21:19162.4336.2860.190010.3651.151.23.20CAD

# Plot revenues by exchange
crypto_pie(table.revenues)


# Plot revenues by reward type
crypto_pie(table.revenues, by = "revenue.type")


Disclaimer: This is not financial advice. Use at your own risks. There are no guarantees whatsoever in relation to the use of this package. Please consult a tax professional as necessary.

Copy Link

Version

Install

install.packages('cryptoTax')

Monthly Downloads

9

Version

0.0.5

License

MIT + file LICENSE

Maintainer

Mr. Cryptoltruist

Last Published

March 12th, 2023

Functions in cryptoTax (0.0.5)

data_binance

Sample data set of a fictive Binance transaction history file
data_cryptotaxcalculator1

Sample data sets provided by cryptotaxcalculator.io
data_celsius

Sample data set of a fictive Celsius transaction history file
data_blockfi

Sample data set of a fictive BlockFi transaction history file
data_coinsmart

Sample data set of a fictive CoinSmart transaction history file
format_ACB

Formats transactions with ACB
data_exodus

Sample data set of a fictive Exodus wallet transaction history file
data_coinpanda1

Sample data sets provided by coinpanda.io
data_adjustedcostbase1

Sample data sets provided by adjustedcostbase.ca
data_binance_withdrawals

Sample data set of a fictive Binance withdrawals transaction history file
data_adalite

Sample data set of a fictive Adalite transaction history file
format_adalite

Format Adalite wallet file
format_CDC

Format Crypto.com App file
format_CDC_wallet

Format CDC wallet file
data_gemini

Sample data set of a fictive Gemini transaction history file
data_shakepay

Sample data set of a fictive Shakepay transaction history file
data_uphold

Sample data set of a fictive Uphold transaction history file
format_binance_withdrawals

Format Binance withdrawal file
format_binance

Format Binance earn file
format_blockfi

Format BlockFi file
format_gemini

Format Gemini file
data_generic1

Sample data sets of fictive generic transaction history files
format_coinsmart

Format CoinSmart file
format_detect

Detect transaction file exchange and format it
data_koinly

Sample data sets provided by koinly.io
data_newton

Sample data set of a fictive Newton transaction history file
format_suploss

Calculate superficial capital losses
format_generic

Format a generic transaction file
format_pooltool

Format ADA rewards from blockchain CSV
format_newton

Format Newton file
prepare_list_prices

Prepare the list of coins for prices
prepare_report

Prepare info for full crypto tax report
format_presearch

Format Presearch wallet file
format_shakepay

Format Shakepay file
format_dollars

Format numeric values to dollars
get_sup_losses

Get superficial loss amounts
format_celsius

Format Celsius file
format_exodus

Format Exodus wallet file
listby_coin

List transactions by coin
match_prices

Get Fair Market Value (FMV) of transactions
format_uphold

Format Uphold file
merge_exchanges

List transactions by coin
report_overview

Summary of ACB
print_report

Print full crypto tax report
data_pooltool

Sample data set of a fictive Cardano PoolTool transaction history file
format_CDC_exchange_rewards

Format CDC exchange file (FOR REWARDS ONLY)
report_revenues

Report all revenues
format_CDC_exchange_trades

Format CDC exchange file (FOR TRADES ONLY)
get_latest_transactions

Get the date from the latest transactions per exchange
data_presearch

Sample data set of a fictive Presearch transaction history file
report_summary

Summary of gains and losses
get_proceeds

Get proceeds of all sold coins
tax_table

Format tax table for final HTML report
tax_box

Get a simple table of relevant tax information
cryptoTax-package

cryptoTax: Report Crypto Taxes (Canada Only)
crypto_pie

Make a pie chart of your crypto revenues
check_missing_transactions

View rows with negative total balances
USD2CAD

Convert USD to CAD
check_new_transactions

Check for new transactions
ACB

Calculate capital gains from realized gain transactions
data_CDC_exchange_trades

Sample data set of a fictive Crypto.com exchange trades transaction history file
data_CDC_exchange_rewards

Sample data set of a fictive Crypto.com exchange rewards transaction history file
data_CDC_wallet

Sample data set of a fictive Crypto.com wallet transaction history file
data_CDC

Sample data set of a fictive Crypto.com transaction history file