Last active
November 3, 2015 04:17
-
-
Save sgreenfield/9258036 to your computer and use it in GitHub Desktop.
Coinbase Average Price Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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