-
-
Save einSelbst/7add97e0cebc5bfa449f4ebaaa7a22fe to your computer and use it in GitHub Desktop.
Revisions
-
AJolly revised this gist
Jul 12, 2019 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -227,6 +227,14 @@ // Insert USD Balance div $('.announcementsDropdown').before('<a class="_1mNCXSUh usdBalance noHover" href="/app/wallet"><span class="noBorder tooltipWrapper"><table class="visible-lg visible-md"><tbody><tr><td class="_39qDSUxb">Total</td><td class="balance-usd-total">0.00 USD</td></tr><tr><td class="_39qDSUxb">Avail</td><td class="balance-usd-avail">0.00 USD</td></tr></tbody></table></span></a><span class="_2wx45MYS visible-lg visible-md"></span>'); console.log('Updating....'); updateIndexPrice(); updateWalletBalances(); updatePNLs(true); $('td.unrealisedPnl > div').hover(function() { updatePNLs(false); }); // Update Functions setInterval(() => { console.log('Updating....'); @@ -236,7 +244,7 @@ $('td.unrealisedPnl > div').hover(function() { updatePNLs(false); }); }, 45000); }); })(); -
AJolly revised this gist
Jul 12, 2019 . 1 changed file with 24 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // ==UserScript== // @name BitMex USD Converter // @namespace https://bitmex.com/ // @version 0.13 // @description Get some sanity into your gambling. // @author koinkraft, modified by @Jolly - https://www.twitter.com/Jolly // @grant none @@ -12,6 +12,8 @@ // @updateURL https://gist.github.com/AJolly/b45e8f97ef04b11124b2971bcb685c4a/raw/bitmexusd.user.js // ==/UserScript== //0.13 = Adds Margin Balance //Updated to show BTC and USD prices in more locations. // USD profit/loss does not taken into account the change in value of your BTC. // ex - if you do a 1x btc short for 10kusd worth of btc, and BTC goes from 11k to 15k, bitmex will say you lost .19btc. my script will say you lost -2.7k USD. but your actual USD net p&l is 0. ) @@ -21,7 +23,7 @@ // Script vars let indexPrice = 0; let currentBalance = {total: 0, avail: 0, margin:0}; // Extract BitMex price const updateIndexPrice = () => { @@ -36,10 +38,24 @@ }, 1000); }; // Extract Wallet Balance const extractWalletBalance = (callback) => { let balances = currentBalance; $('#content > div > span > div.content.container > div > div > div.resizesensor-wrapper > div.react-grid-layout.gridLayout > div.react-grid-item.widget-container.marginDisplayWrapper.react-draggable.cssTransforms.react-resizable > section > div > div > div.rows > div:nth-child(3) > div > div > span').each(function() { let balanceMargin = formatXBTString($(this).html()); if(balanceMargin !== false) balances.margin = balanceMargin; }); $('a[href="/app/wallet"] > span > table > tbody > tr').each(function() { let currentLabel = ''; let balanceTotal = formatXBTString($(this).html()); }); $('a[href="/app/wallet"] > span > table > tbody > tr').each(function() { let currentLabel = ''; $(this).children('td').each(function() { if($(this).html() == 'Total' || $(this).html() == 'Avail') { @@ -59,9 +75,11 @@ callback(balances); }; // Set USD Wallet Balance const setWalletBalance = (updatedBalances) => { if(updatedBalances.total + ' USD | Margin:$' + updatedBalances.margin != $('.balance-usd-total').html()) $('.balance-usd-total').html(updatedBalances.total + ' USD | Margin:$' + updatedBalances.margin); if(updatedBalances.avail + ' USD' != $('.balance-usd-avail').html()) $('.balance-usd-avail').html(updatedBalances.avail + ' USD'); }; @@ -87,7 +105,7 @@ setTimeout(function() { if(indexPrice != 0) { extractWalletBalance(function(balances) { let updatedBalances = {total: (balances.total*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}), avail: (balances.avail*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}),margin: (balances.margin*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2})}; setWalletBalance(updatedBalances); }); } -
AJolly revised this gist
Jul 12, 2019 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,9 @@ // @updateURL https://gist.github.com/AJolly/b45e8f97ef04b11124b2971bcb685c4a/raw/bitmexusd.user.js // ==/UserScript== //Updated to show BTC and USD prices in more locations. // USD profit/loss does not taken into account the change in value of your BTC. // ex - if you do a 1x btc short for 10kusd worth of btc, and BTC goes from 11k to 15k, bitmex will say you lost .19btc. my script will say you lost -2.7k USD. but your actual USD net p&l is 0. ) (function() { 'use strict'; -
AJolly revised this gist
Jul 12, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace https://bitmex.com/ // @version 0.12 // @description Get some sanity into your gambling. // @author koinkraft, modified by @Jolly - https://www.twitter.com/Jolly // @grant none // @include https://bitmex.com/* // @include https://www.bitmex.com/* -
AJolly revised this gist
Jul 12, 2019 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,8 @@ // @include https://bitmex.com/* // @include https://www.bitmex.com/* // @require https://code.jquery.com/jquery-2.1.4.min.js // @downloadURL https://gist.github.com/AJolly/b45e8f97ef04b11124b2971bcb685c4a/raw/bitmexusd.user.js // @updateURL https://gist.github.com/AJolly/b45e8f97ef04b11124b2971bcb685c4a/raw/bitmexusd.user.js // ==/UserScript== //Updated to show BTC and USD prices in more locations. -
AJolly renamed this gist
Jul 12, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
AJolly revised this gist
Jul 12, 2019 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,17 @@ // ==UserScript== // @name BitMex USD Converter // @namespace https://bitmex.com/ // @version 0.12 // @description Get some sanity into your gambling. // @author koinkraft, modified by Jolly // @grant none // @include https://bitmex.com/* // @include https://www.bitmex.com/* // @require https://code.jquery.com/jquery-2.1.4.min.js // ==/UserScript== //Updated to show BTC and USD prices in more locations. (function() { 'use strict'; @@ -109,9 +111,9 @@ let unrealizedPNLUSD = (formatUnrealizedPNL*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}); let newDivContent; if(!isSpan) { newDivContent = unrealizedPNLUSD + ' USD | ' + ' BTC ' + formatUnrealizedPNL + ' ' + parts[2]; } else { newDivContent = '<span style="background:rgba(86,188,118,0.25);" class="' + ( formatUnrealizedPNL*indexPrice < 0 ? 'neg' : 'pos' ) + ' tooltipWrapper hovered">' + unrealizedPNLUSD + ' USD | ' + ' BTC ' + formatUnrealizedPNL + ' ' + parts[2] + '</span>'; } if(newDivContent != $(obj).children('div.unrealizedPnlUSD').html()) { $(obj).children('div.unrealizedPnlUSD').html(newDivContent); @@ -133,8 +135,8 @@ let obj = this; let realizedPNLhover = formatXBTString($(obj).children('.hoverContainer:first-child').children('.hoverVisible').children('.tooltipWrapper').children('span').html()); let realizedPNL = formatXBTString($(obj).children('.hoverContainer:first-child').children('.hoverHidden').children('span').html()); let realizedPNLUSDhoverContent = (realizedPNLhover*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}) + ' USD | BTC ' + realizedPNLhover ; let realizedPNLUSDContent = (realizedPNL*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}) + ' USD | BTC ' + realizedPNL; if($(obj).children('.realizedPNLContainer').children('.hoverVisible').children('.tooltipWrapper').children('span').html() != realizedPNLUSDhoverContent) { $(obj).children('.realizedPNLContainer').children('.hoverVisible').children('.tooltipWrapper').children('span').html(realizedPNLUSDhoverContent); if(realizedPNLhover*indexPrice < 0) { -
QuantBits created this gist
Feb 8, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,218 @@ // ==UserScript== // @name BitMex USD Converter // @namespace https://bitmex.com/ // @version 0.11 // @description Get some sanity into your gambling. // @author koinkraft // @grant none // @include https://bitmex.com/* // @include https://www.bitmex.com/* // @require https://code.jquery.com/jquery-2.1.4.min.js // ==/UserScript== (function() { 'use strict'; // Script vars let indexPrice = 0; let currentBalance = {total: 0, avail: 0}; // Extract BitMex price const updateIndexPrice = () => { $('.instrument').each(function() { let obj = this; if($(obj).children('.symbol').length > 0 && $(obj).children('.symbol').html() == '.BXBT') { indexPrice = $(obj).children('.price').html(); } }); setTimeout(function() { updateIndexPrice(); }, 1000); }; // Extract Wallet Balance const extractWalletBalance = (callback) => { let balances = currentBalance; $('a[href="/app/wallet"] > span > table > tbody > tr').each(function() { let currentLabel = ''; $(this).children('td').each(function() { if($(this).html() == 'Total' || $(this).html() == 'Avail') { currentLabel = $(this).html(); } else { if(currentLabel == 'Total') { let balanceTotal = formatXBTString($(this).html()); if(balanceTotal !== false) balances.total = balanceTotal; } else if(currentLabel == 'Avail') { let balanceAvail = formatXBTString($(this).html()); if(balanceAvail !== false) balances.avail = balanceAvail; } } }); }); currentBalance = balances; callback(balances); }; // Set USD Wallet Balance const setWalletBalance = (updatedBalances) => { if(updatedBalances.total + ' USD' != $('.balance-usd-total').html()) $('.balance-usd-total').html(updatedBalances.total + ' USD'); if(updatedBalances.avail + ' USD' != $('.balance-usd-avail').html()) $('.balance-usd-avail').html(updatedBalances.avail + ' USD'); }; // Convert XBT String const formatXBTString = (string) => { let parts = string.split(" "); if(parts.length == 2) { if(parts[1] == 'XBT') { return parts[0].replace(",","."); } else if(parts[1] == 'mXBT') { return parts[0].replace(",",".")*0.001; } else if(parts[1] == 'XBt') { return parts[0].replace(".","")*0.00001; } else if(parts[1] == 'μXBT') { return parts[0].replace(".","").replace(",",".")*0.000001; } } return false; }; // Update Wallet Balances const updateWalletBalances = () => { setTimeout(function() { if(indexPrice != 0) { extractWalletBalance(function(balances) { let updatedBalances = {total: (balances.total*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}), avail: (balances.avail*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2})}; setWalletBalance(updatedBalances); }); } updateWalletBalances(); }, 1000); }; // Update PNLs const updatePNLs = (setTimeoutCycle) => { if(indexPrice != 0) { // Unrealized PNL $('td.unrealisedPnl').each(function() { let obj = this; let content; let isSpan = false; if($(this).children('div:first-child').children('span').length > 0) { content = $(this).children('div:first-child').children('span:first-child').html(); isSpan = true; } else { content = $(this).children('div:first-child').html(); } let parts = content.split(" "); if(parts[1] == 'XBT' || parts[1] == 'mXBT' || parts[1] == 'XBt' || parts[1] == 'μXBT') { let formatUnrealizedPNL = formatXBTString(parts[0] + ' ' + parts[1]); let unrealizedPNLUSD = (formatUnrealizedPNL*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}); let newDivContent; if(!isSpan) { newDivContent = unrealizedPNLUSD + ' USD ' + parts[2]; } else { newDivContent = '<span style="background:rgba(86,188,118,0.25);" class="' + ( formatUnrealizedPNL*indexPrice < 0 ? 'neg' : 'pos' ) + ' tooltipWrapper hovered">' + unrealizedPNLUSD + ' USD ' + parts[2] + '</span>'; } if(newDivContent != $(obj).children('div.unrealizedPnlUSD').html()) { $(obj).children('div.unrealizedPnlUSD').html(newDivContent); if(formatUnrealizedPNL*indexPrice < 0) { if(!$(obj).children('div.unrealizedPnlUSD').hasClass('neg')) { $(obj).children('div.unrealizedPnlUSD').addClass('neg').removeClass('pos'); } } else { if(!$(obj).children('div.unrealizedPnlUSD').hasClass('pos')) { $(obj).children('div.unrealizedPnlUSD').addClass('pos').removeClass('neg'); } } } } }); // Realized PNL $('td.combinedRealisedPnl').each(function() { let obj = this; let realizedPNLhover = formatXBTString($(obj).children('.hoverContainer:first-child').children('.hoverVisible').children('.tooltipWrapper').children('span').html()); let realizedPNL = formatXBTString($(obj).children('.hoverContainer:first-child').children('.hoverHidden').children('span').html()); let realizedPNLUSDhoverContent = (realizedPNLhover*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}) + ' USD'; let realizedPNLUSDContent = (realizedPNL*indexPrice).toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2}) + ' USD'; if($(obj).children('.realizedPNLContainer').children('.hoverVisible').children('.tooltipWrapper').children('span').html() != realizedPNLUSDhoverContent) { $(obj).children('.realizedPNLContainer').children('.hoverVisible').children('.tooltipWrapper').children('span').html(realizedPNLUSDhoverContent); if(realizedPNLhover*indexPrice < 0) { if(!$(obj).children('.realizedPNLContainer').children('.hoverVisible').children('.tooltipWrapper').children('span').hasClass('neg')) { $(obj).children('.realizedPNLContainer').children('.hoverVisible').children('.tooltipWrapper').children('span').addClass('neg').removeClass('pos'); } } else { if(!$(obj).children('.realizedPNLContainer').children('.hoverVisible').children('.tooltipWrapper').children('span').hasClass('pos')) { $(obj).children('.realizedPNLContainer').children('.hoverVisible').children('.tooltipWrapper').children('span').addClass('pos').removeClass('neg'); } } } if($(obj).children('.realizedPNLContainer').children('.hoverHidden').children('span').html() != realizedPNLUSDContent) { $(obj).children('.realizedPNLContainer').children('.hoverHidden').children('span').html(realizedPNLUSDContent); if(realizedPNL*indexPrice < 0) { if(!$(obj).children('.realizedPNLContainer').children('.hoverHidden').children('span').hasClass('neg')) { $(obj).children('.realizedPNLContainer').children('.hoverHidden').children('span').addClass('neg').removeClass('pos'); } } else { if(!$(obj).children('.realizedPNLContainer').children('.hoverHidden').children('span').hasClass('pos')) { $(obj).children('.realizedPNLContainer').children('.hoverHidden').children('span').addClass('pos').removeClass('neg'); } } } }); } if(setTimeoutCycle) { setTimeout(function() { updatePNLs(true); }, 50); } }; // Initialize PNL wrapper const initPNLWrapper = (setTimeoutCycle) => { if($('td.unrealisedPnl').length > 0 && $('.unrealizedPnlUSD').length == 0) { // Unrealized PNL $('td.unrealisedPnl').css('position', 'relative'); $('td.unrealisedPnl > div').css('opacity', '0').css('position','absolute').css('left','0').css('top','0').css('right','0').css('bottom','0'); $('td.unrealisedPnl > div').after('<div class="unrealizedPnl unrealizedPnlUSD">0.00 USD (0.00%)</div>'); // Realized PNL $('td.combinedRealisedPnl > .hoverContainer').hide(); $('td.combinedRealisedPnl > .hoverContainer').after('<span class="hoverContainer realizedPNLContainer"><span class="hoverVisible"><span class="tooltipWrapper"><span>0.00 USD</span></span></span><span class="hoverHidden"><span>0.00 USD</span></span></span>'); } if(setTimeoutCycle) { setTimeout(function() { initPNLWrapper(true); }, 100); } }; // Wait for window to load $(window).load(function() { // Hide BTC balance box $('._1mNCXSUh:first').hide(); $('._2UCMYPbC > ._2wx45MYS:first').hide(); // Init PNL Wrapper initPNLWrapper(true); $(window).resize(function() { initPNLWrapper(false); }); // Insert USD Balance div $('.announcementsDropdown').before('<a class="_1mNCXSUh usdBalance noHover" href="/app/wallet"><span class="noBorder tooltipWrapper"><table class="visible-lg visible-md"><tbody><tr><td class="_39qDSUxb">Total</td><td class="balance-usd-total">0.00 USD</td></tr><tr><td class="_39qDSUxb">Avail</td><td class="balance-usd-avail">0.00 USD</td></tr></tbody></table></span></a><span class="_2wx45MYS visible-lg visible-md"></span>'); // Update Functions setInterval(() => { console.log('Updating....'); updateIndexPrice(); updateWalletBalances(); updatePNLs(true); $('td.unrealisedPnl > div').hover(function() { updatePNLs(false); }); }, 30000); }); })();