format_generic: Format a generic transaction file

View source: R/format_generic.R

format_genericR Documentation

Format a generic transaction file

Description

Format a generic .csv transaction history file. This function requires one transaction per row, so will not work with trades of two coins reported on the same row. For this you will have to split the trade on two rows and have a single currency column per row.

Usage

format_generic(
  data,
  date = "date",
  currency = "currency",
  quantity = "quantity",
  total.price = "total.price",
  spot.rate = "spot.rate",
  transaction = "transaction",
  fees = "fees",
  description = "description",
  comment = "comment",
  revenue.type = "revenue.type",
  exchange = "exchange",
  timezone = "UTC",
  force = FALSE,
  list.prices = NULL
)

Arguments

data

The dataframe

date

The date column

currency

The currency column

quantity

The quantity column

total.price

The total.price column, if available

spot.rate

The spot.rate column, if available

transaction

The transaction column

fees

The fees column, if available

description

The description column, if available

comment

The comment column, if available

revenue.type

The revenue.type column, if available (content can be one of c("airdrops", "referrals", "staking", "promos", "interests", "rebates", "rewards", "forks", "mining"))

exchange

The exchange column

timezone

The time zone of the transactions

force

Whether to force recreating list.prices even though it already exists (e.g., if you added new coins or new dates).

list.prices

A list.prices object from which to fetch coin prices.

Value

A data frame of exchange transactions, formatted for further processing.

Examples

# Detects correct names even with capitals
format_generic(data_generic1)

# In other cases, names can be specified explicitly:
format_generic(
  data_generic2,
  date = "Date.Transaction",
  currency = "Coin",
  quantity = "Amount",
  total.price = "Price",
  transaction = "Type",
  fees = "Fee",
  exchange = "Platform"
)

# If total.price is missing, it will calculate it based
# on the spot.rate, if available
format_generic(data_generic3)

# If both total.price and spot.rate are missing, it will
# scrap the spot.rate from coinmarketcap based on the coin:
format_generic(data_generic4)


cryptoTax documentation built on March 7, 2023, 7:46 p.m.