Skip to content

Instantly share code, notes, and snippets.

@0xdevalias
Last active August 11, 2025 08:43
Show Gist options
  • Select an option

  • Save 0xdevalias/a1d8344b93a86cbb8a2d9198b81804c9 to your computer and use it in GitHub Desktop.

Select an option

Save 0xdevalias/a1d8344b93a86cbb8a2d9198b81804c9 to your computer and use it in GitHub Desktop.
Spreadsheet formulae for validating/verifying CoinTracking data

CoinTracking Spreadsheet Formulae

Spreadsheet formulae for validating/verifying CoinTracking data.

Table of Contents

Cumulative Total

For a CoinTracking export with headings in columns A-K like this, and newer transactions on top:

Type,Buy,Cur.,Sell,Cur.,Fee,Cur.,Exchange,Group,Comment,Date

We can create a new column in L1 with the name of the asset we want a running total of (eg. NEXO), then starting from L2, we can add this formula and fill it down the column:

Note: Check your data and see if there are any other cases that need to be handled as well

=L3 + IFS(
  AND($A2="Deposit",    $C2=L$1), $B2,
  AND($A2="Withdrawal", $E2=L$1), -1 * $D2,
  AND($A2="Trade",      $C2=L$1), $B2,
  AND($A2="Trade",      $E2=L$1), -1 * $D2,
  AND($A2="Other Fee",  $E2=L$1), -1 * $D2,
  TRUE, 0
)

If we also wanted to add another column where we could add manual adjustments to be included, we could add another title in M1 (name doesn't matter, but lets use NEXO Adjustment for likely duplicate), then starting from L2, we can add this formula and fill it down the column instead:

=L3 + IFS(
  AND($A2="Deposit",    $C2=L$1), $B2,
  AND($A2="Withdrawal", $E2=L$1), -1 * $D2,
  AND($A2="Trade",      $C2=L$1), $B2,
  AND($A2="Trade",      $E2=L$1), -1 * $D2,
  AND($A2="Other Fee",  $E2=L$1), -1 * $D2,
  TRUE, 0
) + IF(NOT(ISBLANK($M2)), $M2, 0)

See Also

My Other Related Deepdive Gist's and Projects

@0xdevalias
Copy link
Author

Some other Google Sheets variations on a pattern similar to this, without needing to manually fill it down the column:

=SCAN(0, H2:H, LAMBDA(accountBalance, tradeAmount, 
  IF(tradeAmount="", "", LET(
    tradeType, INDEX(F:F, ROW(tradeAmount)),
    balanceDelta, IF(OR(tradeType="SELL", tradeType="WITHDRAW"), -tradeAmount, tradeAmount),
    rawResult, accountBalance + balanceDelta,
    ROUND(rawResult, 10)
  ))
))
=SCAN(0, I2:I, LAMBDA(accountBalance, btcAmount, 
  IF(btcAmount="", "", LET(
    row, ROW(btcAmount),
    tradeType, INDEX(F:F, row),
    fee, INDEX(J:J, row),
    balanceDelta, IF(tradeType="SELL", btcAmount, -btcAmount),
    rawResult, accountBalance + balanceDelta - fee,
    ROUND(rawResult, 10)
  ))
))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment