
Format CDC exchange file (FOR TRADES ONLY)
Source:R/format_CDC_exchange_trades.R
format_CDC_exchange_trades.Rd
Format a .csv transaction history file from the Crypto.com
exchange for later ACB processing. Only processes trades, not rewards
(see format_CDC_exchange_rewards
for this).
Details
Original file name of the right file from the exchange is called "SPOT_TRADE.csv", make sure you have the right one. It can usually be accessed with the following steps: (1) connect to the CDC exchange. On the left menu, click on "Wallet", and choose the "Transactions" tab. Pick your desired dates. Unfortunately, the CDC exchange history export only supports 30 days at a time. So if you have more than that, you will need to export each file and merge them manually before you use this function.
As of the new changes to the exchange (3.0) transactions before November 1st, 2022, one can go instead through the "Archive" button on the left vertical menu, choose dates (max 100 days), and download trade transactions. It will be a zip file with several transaction files inside. Choose the "SPOT_TRADE.csv".
In newer versions of this transaction history file, CDC has added
three disclaimer character lines at the top of the file, which is
messing with the headers. Thus, when reading the file with
read.csv()
, add the argument skip = 3
. You will then be able to
read the file normally.
Update 2024: the unzipped correct file is now named "OEX_TRADE.csv" instead of "SPOT_TRADE.csv".
Also note that the USD bundle ("USD_Stable_Coin") is treated as USDC for our purposes since it can be withdrawn as USDC and it is easier to calculate prices with CoinMarketCap and later capital gains and so on.
Examples
format_CDC_exchange_trades(data_CDC_exchange_trades)
#> Object 'list.prices' already exists. Reusing 'list.prices'. To force a fresh download, use argument 'force = TRUE'.
#> Object 'list.prices' already exists. Reusing 'list.prices'. To force a fresh download, use argument 'force = TRUE'.
#> date currency quantity total.price spot.rate transaction
#> 1 2021-12-24 15:34:45 CRO 13260.1300 10383.49502 0.7830613 buy
#> 2 2021-12-24 15:34:45 ETH 2.0932 10383.49502 4960.5842834 sell
#> 3 2021-12-24 15:34:45 CRO 3555.9000 2784.48778 0.7830613 buy
#> 4 2021-12-24 15:34:45 ETH 0.5600 2784.48778 4972.2996075 sell
#> 5 2021-12-24 15:34:45 CRO 1781.7400 1395.21169 0.7830613 buy
#> 6 2021-12-24 15:34:45 ETH 0.2800 1395.21169 4982.8989019 sell
#> 7 2021-12-24 15:34:45 CRO 26.8500 21.02520 0.7830613 buy
#> 8 2021-12-24 15:34:45 ETH 0.0042 21.02520 5005.9992112 sell
#> 9 2021-12-24 15:34:45 CRO 26.6700 20.88425 0.7830613 buy
#> 10 2021-12-24 15:34:45 ETH 0.0042 20.88425 4972.4394399 sell
#> 11 2021-12-24 15:34:45 CRO 17.7800 13.92283 0.7830613 buy
#> 12 2021-12-24 15:34:45 CRO 17.7800 13.92283 0.7830613 buy
#> 13 2021-12-24 15:34:45 ETH 0.0028 13.92283 4972.4394399 sell
#> 14 2021-12-24 15:34:45 ETH 0.0028 13.92283 4972.4394399 sell
#> fees description comment exchange rate.source
#> 1 NA BUY ETH_CRO CDC.exchange coinmarketcap
#> 2 41.53398371 SELL ETH_CRO CDC.exchange coinmarketcap (buy price)
#> 3 NA BUY ETH_CRO CDC.exchange coinmarketcap
#> 4 11.13794862 SELL ETH_CRO CDC.exchange coinmarketcap (buy price)
#> 5 NA BUY ETH_CRO CDC.exchange coinmarketcap
#> 6 5.58085805 SELL ETH_CRO CDC.exchange coinmarketcap (buy price)
#> 7 NA BUY ETH_CRO CDC.exchange coinmarketcap
#> 8 0.08411163 SELL ETH_CRO CDC.exchange coinmarketcap (buy price)
#> 9 NA BUY ETH_CRO CDC.exchange coinmarketcap
#> 10 0.08353356 SELL ETH_CRO CDC.exchange coinmarketcap (buy price)
#> 11 NA BUY ETH_CRO CDC.exchange coinmarketcap
#> 12 NA BUY ETH_CRO CDC.exchange coinmarketcap
#> 13 0.05568992 SELL ETH_CRO CDC.exchange coinmarketcap (buy price)
#> 14 0.05568983 SELL ETH_CRO CDC.exchange coinmarketcap (buy price)