Skip to content

Instantly share code, notes, and snippets.

@sgreenfield
Last active November 3, 2015 04:17
Show Gist options
  • Save sgreenfield/9258036 to your computer and use it in GitHub Desktop.
Save sgreenfield/9258036 to your computer and use it in GitHub Desktop.
Coinbase Average Price Calculator
// Go to the URL below and execute this JavaScript to calculate your coinbase average Bitcoin purchase price and the total purchased.
// https://coinbase.com/transfers
// Bookmarklet can be found here: https://gist.github.com/sgreenfield/9258154
var $rows = $('#transfers_list tr:gt(0)'), orders = [], totalQuantity = 0, totalPrice = 0;
$rows.each(function(){
var rate = $.trim( $(this).find('td:eq(5)').text() ).split(' ')[0] * 1,
quantity = $.trim( $(this).find('td:eq(3)').text() ).split(' ')[0] * 1;
orders.push({ quantity: quantity, rate: rate });
});
$.each(orders, function(i, order){
var price = order.rate * order.quantity;
totalQuantity += order.quantity;
totalPrice += price;
});
alert('paid average of: ' + (totalPrice / totalQuantity) + ' for ' + totalQuantity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment