File tree Expand file tree Collapse file tree 5 files changed +26
-6
lines changed
__tests__/block-tests/tools-test
view/blockly/blocks/tools Expand file tree Collapse file tree 5 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ export default Interface =>
29
29
notifyTelegram : this . notifyTelegram ,
30
30
getTotalRuns : ( ) => this . tradeEngine . getTotalRuns ( ) ,
31
31
getBalance : type => this . tradeEngine . getBalance ( type ) ,
32
- getTotalProfit : ( ) => this . tradeEngine . getTotalProfit ( ) ,
32
+ getTotalProfit : toString =>
33
+ this . tradeEngine . getTotalProfit ( toString , this . tradeEngine . tradeOptions . currency ) ,
33
34
} ;
34
35
}
35
36
} ;
Original file line number Diff line number Diff line change @@ -86,9 +86,14 @@ export default Engine =>
86
86
const accountStat = this . getAccountStat ( ) ;
87
87
return accountStat . totalRuns ;
88
88
}
89
- getTotalProfit ( ) {
89
+ getTotalProfit ( toString , currency ) {
90
90
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 ;
92
97
}
93
98
/* eslint-enable */
94
99
checkLimits ( tradeOption ) {
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ describe('Misc. tools', () => {
17
17
Bot.notify({ message: 'Test', className: 'info'})
18
18
watch('before')
19
19
result.totalRuns = Bot.getTotalRuns();
20
- result.totalProfit = Bot.getTotalProfit();
20
+ result.totalProfit = Bot.getTotalProfit(false, null );
21
21
result.balance = Bot.getBalance('NUM')
22
22
result.balanceStr = Bot.getBalance('STR')
23
23
`
@@ -47,7 +47,9 @@ describe('Misc. tools', () => {
47
47
} ) ;
48
48
49
49
it ( 'Notify' , ( ) => {
50
- const { notify : { className, message } } = observed ;
50
+ const {
51
+ notify : { className, message } ,
52
+ } = observed ;
51
53
52
54
expect ( className ) . equal ( 'info' ) ;
53
55
expect ( message ) . equal ( 'Test' ) ;
Original file line number Diff line number Diff line change @@ -23,4 +23,15 @@ Blockly.Blocks.total_profit = {
23
23
}
24
24
} ,
25
25
} ;
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 ] ;
Original file line number Diff line number Diff line change 440
440
<category name =" Misc." i18n-text =" Misc." >
441
441
<block type =" balance" ></block >
442
442
<block type =" total_profit" ></block >
443
+ <block type =" total_profit_string" ></block >
443
444
<block type =" total_runs" ></block >
444
445
<block type =" notify" >
445
446
<field name =" NOTIFICATION_TYPE" >success</field >
You can’t perform that action at this time.
0 commit comments