I was inspired to set up my own small cryptocurrency index fund by the post https://steemit.com/bitcoin/@cryptoeagle/what-percentage-should-you-invest-in-each-cryptocurrency-to-become-a-multi-millionaire-a-winning-index-strategy-updated-8-24 by @cryptoeagle. However I found it difficult to keep track of how my index fund was doing so I setup a Google spreadsheet to track it.
It updates automatically everyday and gives me a quick snapshot of how I am doing.
In this tutorial I will show you how to create your own Google spreadsheet to keep track all of all of your cryptocurrency holdings and to see how your portfolio is doing over time. If you don’t want to set it all up from scratch you can use the one I made for this tutorial as a template.
You can find the sample sheet here:
https://docs.google.com/spreadsheets/d/1gKLzT5LVJ2tKUufV-de8KjBXFRpYrtA45ahucz03hTA/edit?usp=sharing
To edit it click File -> Make a Copy…
This will save a copy of the spreadsheet to your drive that you can edit.
Step 1
Go to your Google drive and create a new Google spreadsheet. Name it what you want, I’m using Portfolio Performance
Step 2
Go to the Script Editor under Tools. This should open up the script editor in a new tab.
Step 4
From Github copy and paste this code into the script editor.
This code has a lot of useful functions that will allow us to automatically import information from the coinmarketcap.com API.
Step 5
Go back to the Coin Holding Performance sheet and build a table like the one shown below with all of the crypto curriences you hold.
Place the name or symbol of each currency in column A and the quantity in column B. Column C is how much you paid for the current quantity or your cost basis. If you didn’t buy it all at once you will need break it up into chunks to calculate your cost basis. In the example shown the portfolio has 4 Bitcoins, 1 was purchased at $15, 1 at $3000, 1 at $4500, and 1 at $4300. If you don’t know the exact amount you paid you can use the historical data table on coinmarketcap.com to get close. (All of the numbers used here are made up for the purpose of this tutorial)
Step 6
In Column D we are going to put the current USD value the currency is trading at. This is where our Import JSON script will pull the current price from coinmarketcap and pop the value into our sheet. Paste this formula into cell D2 to get the current price of bitcoin in USD.
=ImportJSON( "https://api.coinmarketcap.com/v1/ticker/bitcoin/?convert=USD","/price_usd","noHeaders")
This formula can be changed to get the current price of any currency currently listed on coinmarketcap. For Ethereum it looks like this:
=ImportJSON( "https://api.coinmarketcap.com/v1/ticker/Ethereum/?convert=USD","/price_usd","noHeaders")
Calculating column E is simply a matter of multiplying column D by column B.
The percent gained or lost is then calculated by subtracting the costs basis (C) from the current value (D) and dividing the result by the cost basis (C).
function daily() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName("Performance");
sh.insertRowAfter(1);
sh.getRange("A2").setFormula('=A3+1');
sh.getRange("B2").setFormula('=sum(Holdings!C2:C22)');
sh.getRange("C2").setFormula('=sum(Holdings!E2:E22)');
sh.getRange("D2").setFormula('=(C2-B2)/C2');
var freeze = sh.getRange("A3:B3");
freeze.copyTo(freeze,{contentsOnly:true});
}