Visualizza BitMEX PNL in valori USD – Strumento di conversione USD per Bitmex.com
Nuovo su BitMEX? Iscriviti utilizzando il nostro link per uno sconto del 10% sulle tue commissioni di trading:
https://www.bitmex.com/register/fMRfzN
BitMEX è una piattaforma di trading denominata interamente in Bitcoin. La maggior parte di voi trader sa che questo scambio accetta solo depositi Bitcoin. Paga tutti i tuoi profitti in XBT e mostra solo il tuo PnL rilasciato / inedito in XBT / BTC. Non sarebbe bello se Bitmex mostrasse la denominazione in USD al tuo PnL insieme ai valori BTC?
I popolari contratti swap perpetui XBTUSD, ETHUSD, XRPUSD sono tutti inversi. Significa che sono valutati in USD. Tuttavia, tutto il tuo PNL (profitti e perdite) viene calcolato in Bitcoin. All’inizio può essere abbastanza difficile da capire in quanto non è così semplice come calcolare il tuo PnL sul mercato spot. Quindi è intelligente cambiare la valuta da XBT a USD per rendere le cose più facili. Soprattutto questo è ottimo per gli utenti che stanno monitorando il loro PnL in USD.
La seguente guida spiega come aggiungere la denominazione in USD alla colonna PNL di Bitmex.com.
Come visualizzare BitMEX PnL in valori USD
La piattaforma di trading di derivati Bybit mostra il PNL sia in USD che in BTC.

Sebbene Bitmex non offra questa funzione per impostazione predefinita, possiamo comunque utilizzare un plug-in del browser per contrassegnare PnL in USD.
Per implementarlo avremo bisogno di due cose: 1. Estensione per browser di terze parti e 2. Un codice JavaScript open source.
Installazione dell’estensione del browser Tampermonkey
Tampermonkey è un popolare gestore di script utente. Questa estensione è disponibile per Chrome, Firefox, Brave browser, Microsoft Edge, Safari e Opera.
Browser Chrome e Brave: https://chrome.google.com/webstore/search/tampermonkey

Per Firefox puoi usare Tampermonkey o Greasemonkey. Entrambe le estensioni funzionano. Comunque in questa guida useremo Tampermonkey.
Firefox: https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/
https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/
O semplicemente vai a https://www.tampermonkey.net e aggiungi l’estensione a qualsiasi browser pertinente su cui stai operando.
Dopo aver aggiunto l’estensione al tuo browser dovresti vedere l’icona Tampermonkey nell’angolo in alto a destra.

Installazione dello script del convertitore BitMEX USD
Fare clic sull’icona Tampermonkey nell’angolo in alto a destra e scegliere “Crea un nuovo script” dal menu.
Ora elimina tutto dall’editor e incolla il seguente script.
// == UserScript ==
// @name BitMex USD Converter
// @namespace https://bitmex.com/
// @version 0.11
// Denominazione @description USD per BitMEX PnL
// @autore koinkraft
// @grant none
// @include https://bitmex.com/*
// @include https://www.bitmex.com/*
// @require https://code.jquery.com/jquery-2.1.4.min.js
// == / UserScript ==
(funzione() {
‘usa rigoroso’;
// Script vars
let indexPrice = 0;
let currentBalance = {total: 0, avail: 0};
// Estrai il prezzo di BitMex
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);
};
// Estrai saldo di Wallet
const extractWalletBalance = (callback) => {
let saldi = currentBalance;
$ (‘a [href ="/ app / wallet"] > span > tavolo > tbody > tr ‘). each (function () {
let currentLabel = ”;
$ (this) .children (‘td’). each (function () {
if ($ (this) .html () == ‘Total’ || $ (this) .html () == ‘Avail’) {
currentLabel = $ (questo) .html ();
} altro {
if (currentLabel == ‘Total’) {
let balanceTotal = formatXBTString ($ (questo) .html ());
if (balanceTotal! == false) balances.total = balanceTotal;
} else if (currentLabel == ‘Avail’) {
let balanceAvail = formatXBTString ($ (this) .html ());
if (balanceAvail! == false) balances.avail = balanceAvail;
}
}
});
});
currentBalance = saldi;
callback (saldi);
};
// Imposta il saldo di Wallet in USD
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’);
};
// Converti stringa XBT
const formatXBTString = (stringa) => {
let parts = string.split (" ");
if (parts.length == 2) {
if (parti [1] == “XBT”) {
return parts [0] .replace (",",".");
} altrimenti se (parti [1] == ‘mXBT’) {
return parts [0] .replace (",",".") * 0,001;
} altrimenti if (parti [1] == ‘XBt’) {
return parts [0] .replace (".","") * 0,00001;
} altrimenti se (parti [1] == ‘μXBT’) {
return parts [0] .replace (".","").sostituire(",",".") * 0,000001;
}
}
return false;
};
// Aggiorna i saldi del portafoglio
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);
};
// Aggiorna PNL
const updatePNLs = (setTimeoutCycle) => {
if (indexPrice! = 0) {
// PNL non realizzato
$ (‘td.unrealisedPnl’). each (function () {
let obj = this;
lasciare il contenuto;
let isSpan = false;
if ($ (this) .children (‘div: first-child’). children (‘span’). length > 0) {
contenuto = $ (questo) .children (‘div: first-child’). children (‘span: first-child’). html ();
isSpan = true;
} altro {
contenuto = $ (questo) .children (‘div: first-child’). html ();
}
let parts = content.split (" ");
if (parti [1] == ‘XBT’ || parti [1] == ‘mXBT’ || parti [1] == ‘XBt’ || parti [1] == ‘μXBT’) {
let formatUnrealizedPNL = formatXBTString (parti [0] + ” + parti [1]);
let unrealizedPNLUSD = (formatUnrealizedPNL * indexPrice) .toLocaleString (‘en-US’, {minimumFractionDigits: 2, maximumFractionDigits: 2});
let newDivContent;
if (! isSpan) {
newDivContent = non realizzatoPNLUSD + ‘USD | ‘+’ BTC ‘+ formatUnrealizedPNL +’ ‘+ parti [2];
} altro {
newDivContent = ” + unrealizedPNLUSD + ‘USD | ‘+’ BTC ‘+ formatUnrealizedPNL +’ ‘+ parti [2] +’ ‘;
}
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’);
}
} altro {
if (! $ (obj) .children (‘div.unrealizedPnlUSD’). hasClass (‘pos’)) {
$ (obj) .children (‘div.unrealizedPnlUSD’). addClass (‘pos’). removeClass (‘neg’);
}
}
}
}
});
// PNL realizzato
$ (‘td.combinedRealisedPnl’). each (function () {
let obj = this;
let madePNLhover = formatXBTString ($ (obj) .children (‘. hoverContainer: first-child’). children (‘. hoverVisible’). children (‘. tooltipWrapper’). children (‘span’). html ());
let madePNL = formatXBTString ($ (obj) .children (‘. hoverContainer: first-child’). children (‘. hoverHidden’). children (‘span’). html ());
let madePNLUSDhoverContent = (madePNLhover * indexPrice) .toLocaleString (‘en-US’, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + ‘USD’;
let madePNLUSDContent = (madePNL * indexPrice) .toLocaleString (‘en-US’, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + ‘USD’;
if ($ (obj) .children (‘. madePNLContainer’). children (‘. hoverVisible’). children (‘. tooltipWrapper’). children (‘span’). html ()! = madePNLUSDhoverContent) {
$ (obj) .children (‘. madePNLContainer’). children (‘. hoverVisible’). children (‘. tooltipWrapper’). children (‘span’). html (madePNLUSDhoverContent);
if (madePNLhover * indexPrice < 0) {
if (! $ (obj) .children (‘. madePNLContainer’). children (‘. hoverVisible’). children (‘. tooltipWrapper’). children (‘span’). hasClass (‘neg’)) {
$ (obj) .children (‘. madePNLContainer’). children (‘. hoverVisible’). children (‘. tooltipWrapper’). children (‘span’). addClass (‘neg’). removeClass (‘pos’);
}
} altro {
if (! $ (obj) .children (‘. madePNLContainer’). children (‘. hoverVisible’). children (‘. tooltipWrapper’). children (‘span’). hasClass (‘pos’)) {
$ (obj) .children (‘. madePNLContainer’). children (‘. hoverVisible’). children (‘. tooltipWrapper’). children (‘span’). addClass (‘pos’). removeClass (‘neg’);
}
}
}
if ($ (obj) .children (‘. madePNLContainer’). children (‘. hoverHidden’). children (‘span’). html ()! = madePNLUSDContent) {
$ (obj) .children (‘. madePNLContainer’). children (‘. hoverHidden’). children (‘span’). html (madePNLUSDContent);
if (madePNL * indexPrice < 0) {
if (! $ (obj) .children (‘. madePNLContainer’). children (‘. hoverHidden’). children (‘span’). hasClass (‘neg’)) {
$ (obj) .children (‘. madePNLContainer’). children (‘. hoverHidden’). children (‘span’). addClass (‘neg’). removeClass (‘pos’);
}
} altro {
if (! $ (obj) .children (‘. madePNLContainer’). children (‘. hoverHidden’). children (‘span’). hasClass (‘pos’)) {
$ (obj) .children (‘. madePNLContainer’). children (‘. hoverHidden’). children (‘span’). addClass (‘pos’). removeClass (‘neg’);
}
}
}
});
}
if (setTimeoutCycle) {
setTimeout (function () {
updatePNLs (true);
}, 50);
}
};
// Inizializza wrapper PNL
const initPNLWrapper = (setTimeoutCycle) => {
if ($ (‘td.unrealisedPnl’). length > 0 && $ (‘. unrealizedPnlUSD’). length == 0) {
// PNL non realizzato
$ (‘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 ‘). dopo (‘ 0.00 USD (0.00%) ‘);
// PNL realizzato
$ (‘td.combinedRealisedPnl > .hoverContainer ‘). hide ();
$ (‘td.combinedRealisedPnl > .hoverContainer “). dopo (” 0,00 USD0,00 USD “);
}
if (setTimeoutCycle) {
setTimeout (function () {
initPNLWrapper (true);
}, 100);
}
};
// Attendi il caricamento della finestra
$ (finestra) .load (funzione () {
// Nascondi la casella del saldo BTC
$ (‘._ 1mNCXSUh: primo’). Hide ();
$ (‘._ 2UCMYPbC > ._2wx45MYS: primo ‘). Hide ();
// Init PNL Wrapper
initPNLWrapper (true);
$ (finestra) .resize (function () {
initPNLWrapper (false);
});
// Inserisci div. Saldo in USD
$ (‘. annunciDropdown’). before (‘
| Totale | 0,00 USD |
| Avail | 0,00 USD |
‘);
// Aggiorna funzioni
setInterval (() => {
console.log (‘Aggiornamento ….’);
updateIndexPrice ();
updateWalletBalances ();
updatePNLs (true);
$ (‘td.unrealisedPnl > div ‘). hover (function () {
updatePNLs (false);
});
}, 30000);
});
}) ();
Il codice sopra è un codice JavaScript open source scritto da KoinKraft.
Riferimento: https://gist.github.com/btc-zz/6b8315f93969ee7caf6c3d66e70ec721

Una volta fatto, fai clic su File >> Salva.
Quindi assicurati che lo strumento di conversione Tampermonkey e BitMEX USD sia abilitato. Puoi disabilitare lo script ogni volta che lo desideri.

Ora aggiorna la pagina di trading di Bitmex.com e attendi qualche istante per il caricamento dello script. Una volta caricato, dovrebbe mostrare i valori USD nella colonna PNL. Visualizza sia i valori USD che BTC anziché solo USD. Anche la conversione in USD avviene in tempo reale.

Plug-in non funzionante?
Questo metodo funziona con tutti i principali browser web. Affinché questo plug-in funzioni correttamente, assicurati di impostare la visualizzazione della valuta BitMEX su XBT (Bitcoin). Non funzionerà con altre valute come Satoshi, micro-Bitcoin e milli-Bitcoin. Inoltre, inizialmente ci vuole un po ‘per caricare i valori in USD, quindi dagli un po’ di tempo.
Ci auguriamo che d’ora in poi tu non debba fare alcuna conversione di base da BTC a valuta Fiat o da Satoshi a USD per valutare quanto è il profitto in USD. Lo script fa il lavoro per te.

Facebook
Pinterest