Last active
October 12, 2025 08:19
-
-
Save melardev/5bd64c4d569ec6b157a69e17739e8d46 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
| // Script that you can run in the developer console | |
| // to get the exposure from your positions | |
| // Telastreet offers this feature for the supported exchanges | |
| // and I think it's useful info if you have many positions opened | |
| // MEXC doesn't give that info by default | |
| const elements = document.querySelectorAll('tr.ant-table-row') | |
| exposure = { | |
| 'long': 0, | |
| 'short': 0, | |
| 'raw': [] | |
| } | |
| let tradesCount = 0; | |
| let unknownSizeCount = 0; | |
| for (let i = 0; i < elements.length; i++) { | |
| let valueStr = elements[i].querySelectorAll('td:nth-of-type(2) span span')[0].innerText; | |
| valueStr = valueStr.replace(',', ''); | |
| const side = elements[i].querySelectorAll('td:nth-of-type(1) span.Position_longShortText__qLiND')[0].innerText.trim().toLowerCase(); | |
| try { | |
| const value = parseFloat(valueStr); | |
| if (isNaN(value)) { | |
| console.error('Found invalid value', valueStr) | |
| } else { | |
| if (side === 'long') { | |
| exposure['long'] += value; | |
| exposure['raw'].push(value); | |
| } else { | |
| exposure['short'] -= value; | |
| exposure['raw'].push(-value); | |
| } | |
| tradesCount++; | |
| } | |
| } catch (e) { | |
| console.log(e) | |
| } | |
| } | |
| console.log(`Long exposure: ${exposure['long']}`); | |
| console.log(`Short exposure: ${exposure['short']}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment