Computing True Gain/Loss in Cryptocurrency Tradingby@ourarash
8,954 reads

Computing True Gain/Loss in Cryptocurrency Trading

Read on Terminal Reader

Too Long; Didn't Read

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Computing True Gain/Loss in Cryptocurrency Trading
Ari Saif HackerNoon profile picture


Ari Saif
react to story with heart

Summary: I describe a simple method for accurately calculating the gain/loss for each coin in your portfolio in USD (or any other FIAT currency). I provide a spreadsheet document for the calculation.

Also, I show you how you can use the free app, BitcoinCrazyness, to automatically do that for you.

Disclaimer: I’m the developer of the BitcoinCrazyness app.

Let me begin by a quick example.


  1. You buy 1 BTC for $8,000
  2. A few days later, you buy 1 BTC for $6,000
  3. Then you buy 1 ETH for 0.07 BTC

Suppose today, the prices are:

  • ETH/USD: 935.448
  • ETH/BTC: 0.0799
  • BTC/USD: 11,837.5

How much is your gain/loss for ETH in USD?


For simplicity, assume there is no transaction fees.

Naive Calculation:

Your gain in BTC is:

0.0799 - 0.07= 0.0099 BTC

In order to convert your gain to USD, we multiply the gain in BTC to today’s value of BTC in USD:

0.0099 x 11,837.5 = $117.19

However, this is not the true value of your gain, because the value of BTC changed from the day you bought it several times.

The above calculation completely ignores and is independent of the cost of BTC.

A More Accurate Calculation:

The average cost of each unit of BTC is $7,000 since you bought one unit at $8,000, and one at $6,000.

When you buy 1 ETH for 0.07 BTC, you really are paying:

0.07 × $7000 = $490

Since ETH/USD is now $935.45, your gain would be:

$935.45 - $490 = $445.45

So, your gain is really $445.45, not $117.19.

The following image shows the accurate values for each of your coins:



  • You are left with 1.93 BTC, which you bought for an average unit price of $7,000. So the total cost of it is $13,510
  • Your total BTC is now worth 22,846.375, so your profit on BTC is $9.336.38.
  • Your ETH is now worth $935.448, which cost you $490. Therefore, your true gain is $445.45.

You can do similar calculations either using the free BitcoinCrazyness App, or using this spreadsheet.

A More Complicated Example

Now assume you use your ETH from the previous example and buy some more coins with it. In particular, assume the following is the summary of your transactions:

  1. You buy 1 BTC for $8,000
  2. You buy 1 BTC for $6,000
  3. You buy 1 ETH for 0.07 BTC
  4. You buy 1 XMR for 0.33 ETH
  5. You buy 1 LTC for 0.25 ETH

What is the cost for XMR and LTC?

Solution: each ETH costs you $490. Therefore the cost for XMR and LTC in USD is 0.33 × 490 = $161.7 and 0.25 × $490 = $122.4 respectively.

You can see the gains for each currency in the following picture:


Gain Calculation for Each Coin in USD

In short, gain/loss calculation is not too complicated, but it should account for the average cost of each coin for each transaction. Moreover, it should account for transaction fees.

BitcoinCrazyness App

The BitcoinCrazyness app was started based on the above simple idea. It is a free app that calculates the average cost of each coin and therefore calculates the true gain/loss for each currency in USD and several other FIAT currencies.

In order to enter the transactions quickly, it accepts a CSV file. CSV stands for Comma Separated Value, which is a text file that can be generated from an excel sheet.



Screenshots for BitcoinCrazyness App

The CSV file for the above examples are given at the end of this article.

CSV File Format:

Each trade is specified in one row of the CSV file which has the following columns:


  • “from” and “to” are the currencies for the trade, for example for BTC/USD, from is BTC, and to should be USD
  • “type” is the transaction type. It can be buy, sell, deposit or withdraw, which specifies if we are buying/selling the “from” part of the trade pair.
  • “quantity” is the quantity of the “from” that we are buying/selling.
  • “useHolding” specifies if the app should deduct the cost of the trade for your previous holdings
  • “feeCost” is the transaction cost which can be 0 or higher.
  • “feeCurrency” specifies what currency the fee is in.

The following picture shows the output of the app for an even more complicated example with transaction fees:













The Gain/Loss Calculation with Transaction Fees using the BitcoinCrazyness app


Gain/loss calculation should account for the average cost of each coin for each transaction. The transactions should be entered in a chronological order.

If you liked this article please share, comment, and click on the clap icon a few times. I would love to know how you calculate your gain and loss and if you have any feedback for the BitcoinCrazyness app.

Besides gain/loss calculations, the BitcoinCrazyness app provides advanced trailing delta price alerts, latest prices for thousands of coins, and advanced coin queries.


The CSV files for the first example:





The CSV file for the second example:








. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa