Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit d3669d5

Browse files
authored
Merge pull request #1638 from sam-binary/decimal-missing
Decimal missing
2 parents 3356d2b + b9b5bde commit d3669d5

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

src/botPage/bot/Interface/MiscInterface.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export default Interface =>
2929
notifyTelegram: this.notifyTelegram,
3030
getTotalRuns : () => this.tradeEngine.getTotalRuns(),
3131
getBalance : type => this.tradeEngine.getBalance(type),
32-
getTotalProfit: () => this.tradeEngine.getTotalProfit(),
32+
getTotalProfit: toString =>
33+
this.tradeEngine.getTotalProfit(toString, this.tradeEngine.tradeOptions.currency),
3334
};
3435
}
3536
};

src/botPage/bot/TradeEngine/Total.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,14 @@ export default Engine =>
8686
const accountStat = this.getAccountStat();
8787
return accountStat.totalRuns;
8888
}
89-
getTotalProfit() {
89+
getTotalProfit(toString, currency) {
9090
const accountStat = this.getAccountStat();
91-
return Number(accountStat.totalProfit);
91+
return toString && accountStat.totalProfit !== 0
92+
? roundBalance({
93+
currency,
94+
balance: +accountStat.totalProfit,
95+
})
96+
: +accountStat.totalProfit;
9297
}
9398
/* eslint-enable */
9499
checkLimits(tradeOption) {

src/botPage/bot/__tests__/block-tests/tools-test/Misc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('Misc. tools', () => {
1717
Bot.notify({ message: 'Test', className: 'info'})
1818
watch('before')
1919
result.totalRuns = Bot.getTotalRuns();
20-
result.totalProfit = Bot.getTotalProfit();
20+
result.totalProfit = Bot.getTotalProfit(false, null);
2121
result.balance = Bot.getBalance('NUM')
2222
result.balanceStr = Bot.getBalance('STR')
2323
`
@@ -47,7 +47,9 @@ describe('Misc. tools', () => {
4747
});
4848

4949
it('Notify', () => {
50-
const { notify: { className, message } } = observed;
50+
const {
51+
notify: { className, message },
52+
} = observed;
5153

5254
expect(className).equal('info');
5355
expect(message).equal('Test');

src/botPage/view/blockly/blocks/tools/total_profit.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,15 @@ Blockly.Blocks.total_profit = {
2323
}
2424
},
2525
};
26-
Blockly.JavaScript.total_profit = () => ['Bot.getTotalProfit()', Blockly.JavaScript.ORDER_ATOMIC];
26+
Blockly.JavaScript.total_profit = () => ['Bot.getTotalProfit(false)', Blockly.JavaScript.ORDER_ATOMIC];
27+
28+
Blockly.Blocks.total_profit_string = {
29+
init: function init() {
30+
this.appendDummyInput().appendField(translate('Total Profit String'));
31+
this.setOutput(true, 'String');
32+
this.setColour('#dedede');
33+
this.setTooltip(translate('Return the total profit (String)'));
34+
this.setHelpUrl('https://github.com/binary-com/binary-bot/wiki');
35+
},
36+
};
37+
Blockly.JavaScript.total_profit_string = () => ['Bot.getTotalProfit(true)', Blockly.JavaScript.ORDER_ATOMIC];

static/xml/toolbox.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@
440440
<category name="Misc." i18n-text="Misc.">
441441
<block type="balance"></block>
442442
<block type="total_profit"></block>
443+
<block type="total_profit_string"></block>
443444
<block type="total_runs"></block>
444445
<block type="notify">
445446
<field name="NOTIFICATION_TYPE">success</field>

0 commit comments

Comments
 (0)