Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/botPage/bot/Interface/MiscInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}
};
9 changes: 7 additions & 2 deletions src/botPage/bot/TradeEngine/Total.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions src/botPage/bot/__tests__/block-tests/tools-test/Misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
`
Expand Down Expand Up @@ -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');
Expand Down
13 changes: 12 additions & 1 deletion src/botPage/view/blockly/blocks/tools/total_profit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
1 change: 1 addition & 0 deletions static/xml/toolbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@
<category name="Misc." i18n-text="Misc.">
<block type="balance"></block>
<block type="total_profit"></block>
<block type="total_profit_string"></block>
<block type="total_runs"></block>
<block type="notify">
<field name="NOTIFICATION_TYPE">success</field>
Expand Down