Last active
January 3, 2016 16:39
-
-
Save imcoddy/8490566 to your computer and use it in GitHub Desktop.
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
// ==UserScript==// | |
// @name Huobi Trade Enhancer | |
// @namespace https://www.huobi.com | |
// @version 0.3.1 | |
// @include https://www.huobi.com/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js | |
// ==/UserScript== | |
// add fund in and out to calculate average price | |
var total_cny = 1024; //TODO set it to your total fund in. | |
var user_withdrew_btc = 0; //TODO set it to your total fund out. | |
// add color for trade operation | |
$("td").filter(function() { | |
return $.text([this]) == '买入'; | |
}) | |
.each(function(index){ | |
$(this).html('<span class="label label-warning">买入</span>'); | |
}); | |
$("td").filter(function() { | |
return $.text([this]) == '卖出'; | |
}) | |
.each(function(index){ | |
$(this).html('<span class="label label-success">卖出</span>'); | |
}); | |
$('.hangqing-info-login').append(' 平均价¥:<span class="average_price">0</span>'); | |
$('.hangqing-info-login').append(' 净赚¥:<span class="earned_cny">0</span>'); | |
function calculate_average(){ | |
var user_available_btc = parseFloat($('.user_available_btc').first().text()); | |
var user_frozen_btc = parseFloat($('.user_frozen_btc').first().text()); | |
var user_available_cny = parseFloat($('.user_available_cny').first().text()); | |
var user_frozen_cny = parseFloat($('.user_frozen_cny').first().text()); | |
var current_price = parseFloat($('.hq_t_p_new').first().text().substring(1)); | |
var average_price = parseFloat( (total_cny - user_frozen_cny - user_available_cny) / (user_available_btc + user_frozen_btc + user_withdrew_btc) ).toFixed(2); | |
$('.average_price').text(average_price); | |
var total_cal = $('.user_total').first().text(); | |
var earned_cny = parseFloat(parseFloat(total_cal) - total_cny + current_price * user_withdrew_btc).toFixed(2); | |
$('.earned_cny').text(earned_cny); | |
}; | |
setTimeout(calculate_average, 2000); | |
setInterval(calculate_average, 10000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment