diff --git a/src/botPage/bot/Interface/MiscInterface.js b/src/botPage/bot/Interface/MiscInterface.js index 329c503bf5..b3df72b9ae 100644 --- a/src/botPage/bot/Interface/MiscInterface.js +++ b/src/botPage/bot/Interface/MiscInterface.js @@ -29,7 +29,8 @@ export default Interface => notifyTelegram: this.notifyTelegram, getTotalRuns : () => this.tradeEngine.getTotalRuns(), getBalance : type => this.tradeEngine.getBalance(type), - getTotalProfit: () => this.tradeEngine.getTotalProfit(), + getTotalProfit: toString => + this.tradeEngine.getTotalProfit(toString, this.tradeEngine.tradeOptions.currency), }; } }; diff --git a/src/botPage/bot/TradeEngine/Total.js b/src/botPage/bot/TradeEngine/Total.js index 64a567e559..7433da6aed 100644 --- a/src/botPage/bot/TradeEngine/Total.js +++ b/src/botPage/bot/TradeEngine/Total.js @@ -86,9 +86,14 @@ export default Engine => const accountStat = this.getAccountStat(); return accountStat.totalRuns; } - getTotalProfit() { + getTotalProfit(toString, currency) { const accountStat = this.getAccountStat(); - return Number(accountStat.totalProfit); + return toString && accountStat.totalProfit !== 0 + ? roundBalance({ + currency, + balance: +accountStat.totalProfit, + }) + : +accountStat.totalProfit; } /* eslint-enable */ checkLimits(tradeOption) { diff --git a/src/botPage/bot/__tests__/block-tests/tools-test/Misc.js b/src/botPage/bot/__tests__/block-tests/tools-test/Misc.js index 5e74115fe7..3e79bb3746 100644 --- a/src/botPage/bot/__tests__/block-tests/tools-test/Misc.js +++ b/src/botPage/bot/__tests__/block-tests/tools-test/Misc.js @@ -17,7 +17,7 @@ describe('Misc. tools', () => { Bot.notify({ message: 'Test', className: 'info'}) watch('before') result.totalRuns = Bot.getTotalRuns(); - result.totalProfit = Bot.getTotalProfit(); + result.totalProfit = Bot.getTotalProfit(false, null); result.balance = Bot.getBalance('NUM') result.balanceStr = Bot.getBalance('STR') ` @@ -47,7 +47,9 @@ describe('Misc. tools', () => { }); it('Notify', () => { - const { notify: { className, message } } = observed; + const { + notify: { className, message }, + } = observed; expect(className).equal('info'); expect(message).equal('Test'); diff --git a/src/botPage/view/blockly/blocks/tools/total_profit.js b/src/botPage/view/blockly/blocks/tools/total_profit.js index 57aab906da..dd9851ca72 100644 --- a/src/botPage/view/blockly/blocks/tools/total_profit.js +++ b/src/botPage/view/blockly/blocks/tools/total_profit.js @@ -23,4 +23,15 @@ Blockly.Blocks.total_profit = { } }, }; -Blockly.JavaScript.total_profit = () => ['Bot.getTotalProfit()', Blockly.JavaScript.ORDER_ATOMIC]; +Blockly.JavaScript.total_profit = () => ['Bot.getTotalProfit(false)', Blockly.JavaScript.ORDER_ATOMIC]; + +Blockly.Blocks.total_profit_string = { + init: function init() { + this.appendDummyInput().appendField(translate('Total Profit String')); + this.setOutput(true, 'String'); + this.setColour('#dedede'); + this.setTooltip(translate('Return the total profit (String)')); + this.setHelpUrl('https://github.com/binary-com/binary-bot/wiki'); + }, +}; +Blockly.JavaScript.total_profit_string = () => ['Bot.getTotalProfit(true)', Blockly.JavaScript.ORDER_ATOMIC]; diff --git a/static/xml/toolbox.xml b/static/xml/toolbox.xml index 1e97c00722..faa4aea50d 100644 --- a/static/xml/toolbox.xml +++ b/static/xml/toolbox.xml @@ -440,6 +440,7 @@ + success pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy