Created
September 23, 2023 07:48
-
-
Save RetiredQQ/05c23d4407bf2dd7cd54d892cffb0c29 to your computer and use it in GitHub Desktop.
This file contains 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
// JFX | |
// | |
async function fetchWalletFinances() { | |
const response = await fetch('https://my.hfm.com/en/trader/wallet_finances'); | |
const data = await response.json(); | |
return data; | |
} | |
async function kira() { | |
const data = await fetchWalletFinances(); | |
let totalDeposit = 0; | |
let totalWithdrawal = 0; | |
if (data.D) { | |
totalDeposit = data.D | |
.filter(deposit => deposit.comment.toLowerCase().includes('deposit')) | |
.filter(deposit => !deposit.comment.toLowerCase().includes('performance')) | |
.filter(deposit => !deposit.comment.toLowerCase().includes('withdraw')) | |
.filter(deposit => !deposit.comment.toLowerCase().includes('affiliate')) | |
.filter(deposit => !deposit.comment.toLowerCase().includes('commission')) | |
.filter(deposit => deposit.status.toLowerCase().includes('completed')) | |
.reduce((acc, deposit) => acc + parseFloat(deposit.amount), 0); | |
} | |
if (data.W) { | |
totalWithdrawal = data.W | |
.filter(withdrawal => withdrawal.status.toLowerCase().includes('completed')) | |
.reduce((acc, withdrawal) => acc + parseFloat(withdrawal.amount), 0); | |
} | |
console.log('Total deposit amount: $' + totalDeposit.toFixed(2)); | |
console.log('Total withdrawal amount: $' + totalWithdrawal.toFixed(2)); | |
var profit = 0; | |
if (totalWithdrawal > totalDeposit) { | |
profit = (totalWithdrawal - totalDeposit).toFixed(2); | |
} | |
else { | |
profit = (totalDeposit - totalWithdrawal).toFixed(2); | |
} | |
console.log('Total profit amount: $' + profit); | |
} | |
kira(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment