Created
December 24, 2017 11:20
-
-
Save dseeker/4ac806501b6d8711fa5578a8d593af01 to your computer and use it in GitHub Desktop.
Displays Arbitrage margin in coinmarketcap website (coin page)
This file contains hidden or 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
//Execute in browser console, or inject via CJS (chrome) | |
var config={ | |
min_volume:.5, | |
pair:'BTC' | |
} | |
if (!$('#arbitrage').length){ | |
$('#currency-switch-button').click() | |
$('#currency-switch .price-toggle[data-currency="btc"]').click() | |
var mkts={} | |
$('#markets-table tr[role="row"]').each(function(i,v){ | |
var vol = parseFloat($(v).find('.price').parent().next().text().replace('%','')) | |
var pair = $(v).find('td').eq(2).text() | |
if (vol>=config.min_volume && pair.indexOf(config.pair)>=0) | |
mkts[$(v).find('td').eq(1).text()] = { | |
mkt:$(v).find('td').eq(1).text(), | |
price:parseFloat($(v).find('.price').text().split(' ').shift()), | |
vol:$(v).find('.price').parent().next().text() | |
} | |
}) | |
var min={price:10000},max={price:0} | |
$.each(mkts, function(k,v){ | |
if (v.price>max.price) max=v | |
if (v.price<min.price) min=v | |
}) | |
console.log(mkts) | |
var arb="Arbitrage <span class='positive_change'>("+Math.round(((max.price/min.price)-1)*100)+"%)</span>:<br>"+min.price+" buy @ "+min.mkt+" <br>"+max.price+" sell @ "+max.mkt | |
$('#quote_price').parent().append('<span id="arbitrage" class="details-text-medium text-gray">'+arb+'</span>') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment