diff --git a/src/botPage/bot/Interface/index.js b/src/botPage/bot/Interface/index.js index af3dcf8fd6..eb5d8913be 100644 --- a/src/botPage/bot/Interface/index.js +++ b/src/botPage/bot/Interface/index.js @@ -37,7 +37,7 @@ export default class Interface extends ToolsInterface(TicksInterface(class {})) }; } getBotInterface() { - const getDetail = i => createDetails(this.get('contract'))[i]; + const getDetail = (i, pipSize) => createDetails(this.get('contract'), pipSize)[i]; return { init : (...args) => this.tradeEngine.init(...args), @@ -50,7 +50,7 @@ export default class Interface extends ToolsInterface(TicksInterface(class {})) sellAtMarket : () => this.tradeEngine.sellAtMarket(), getSellPrice : () => this.getSellPrice(), isResult : result => getDetail(10) === result, - readDetails : i => getDetail(i - 1), + readDetails : i => getDetail(i - 1, this.tradeEngine.getPipSize()), }; } sleep(arg = 1) { diff --git a/src/botPage/bot/TradeEngine/Ticks.js b/src/botPage/bot/TradeEngine/Ticks.js index edb85321d9..ac0b38b158 100644 --- a/src/botPage/bot/TradeEngine/Ticks.js +++ b/src/botPage/bot/TradeEngine/Ticks.js @@ -31,18 +31,30 @@ export default Engine => tickListenerKey = key; } } - getTicks() { - return new Promise(resolve => - this.$scope.ticksService - .request({ symbol: this.symbol }) - .then(ticks => resolve(ticks.map(o => o.quote))) - ); + getTicks(toString = false) { + return new Promise(resolve => { + this.$scope.ticksService.request({ symbol: this.symbol }).then(ticks => { + const pipSize = this.getPipSize(); + const ticksList = ticks.map(o => { + if (toString) { + return o.quote.toFixed(pipSize); + } + return o.quote; + }); + + resolve(ticksList); + }); + }); } - getLastTick(raw) { + getLastTick(raw, toString = false) { return new Promise(resolve => - this.$scope.ticksService - .request({ symbol: this.symbol }) - .then(ticks => resolve(raw ? getLast(ticks) : getLast(ticks).quote)) + this.$scope.ticksService.request({ symbol: this.symbol }).then(ticks => { + let lastTick = raw ? getLast(ticks) : getLast(ticks).quote; + if (toString && !raw) { + lastTick = lastTick.toFixed(this.getPipSize()); + } + resolve(lastTick); + }) ); } getLastDigit() { diff --git a/src/botPage/bot/tools.js b/src/botPage/bot/tools.js index 2fbbcf82bf..d4f535ec5b 100644 --- a/src/botPage/bot/tools.js +++ b/src/botPage/bot/tools.js @@ -134,7 +134,7 @@ export const doUntilDone = (f, types) => { }); }; -export const createDetails = contract => { +export const createDetails = (contract, pipSize) => { const { sell_price: sellPrice, buy_price: buyPrice, currency } = contract; const profit = Number(roundBalance({ currency, balance: sellPrice - buyPrice })); const result = profit < 0 ? 'loss' : 'win'; @@ -151,6 +151,8 @@ export const createDetails = contract => { +contract.exit_tick, +(contract.barrier ? contract.barrier : 0), result, + (+contract.entry_tick).toFixed(pipSize), + (+contract.exit_tick).toFixed(pipSize), ]; }; diff --git a/src/botPage/common/const.js b/src/botPage/common/const.js index 844e3fa331..a35f5888bb 100644 --- a/src/botPage/common/const.js +++ b/src/botPage/common/const.js @@ -21,8 +21,10 @@ const config = { [translate('contract type'), '5'], [translate('entry spot'), '6'], [translate('entry value'), '7'], + [translate('entry value string'), '12'], [translate('exit spot'), '8'], [translate('exit value'), '9'], + [translate('exit value string'), '13'], [translate('barrier'), '10'], [translate('result'), '11'], ], diff --git a/src/botPage/view/TradeInfoPanel/TradeTable.js b/src/botPage/view/TradeInfoPanel/TradeTable.js index 1d8eff86c2..1974a4d7fe 100644 --- a/src/botPage/view/TradeInfoPanel/TradeTable.js +++ b/src/botPage/view/TradeInfoPanel/TradeTable.js @@ -50,8 +50,8 @@ export default class TradeTable extends Component { { key: 'timestamp', width: 192, resizable: true, name: translate('Timestamp') }, { key: 'reference', width: 110, resizable: true, name: translate('Reference') }, { key: 'contract_type', width: 70, resizable: true, name: translate('Trade type') }, - { key: 'entry_tick', width: 75, resizable: true, name: translate('Entry spot') }, - { key: 'exit_tick', width: 75, resizable: true, name: translate('Exit spot') }, + { key: 'entry_tick', width: 82, resizable: true, name: translate('Entry spot') }, + { key: 'exit_tick', width: 82, resizable: true, name: translate('Exit spot') }, { key: 'buy_price', width: 80, resizable: true, name: translate('Buy price') }, { key: 'profit', width: 80, resizable: true, name: translate('Profit/Loss'), formatter: ProfitColor }, { key: 'contract_status', width: 70, resizable: true, name: translate('Status'), formatter: StatusFormat }, diff --git a/src/botPage/view/blockly/blocks/ticks/tick.js b/src/botPage/view/blockly/blocks/ticks/tick.js index b449db3bb2..070f535cde 100644 --- a/src/botPage/view/blockly/blocks/ticks/tick.js +++ b/src/botPage/view/blockly/blocks/ticks/tick.js @@ -14,4 +14,16 @@ Blockly.Blocks.tick = { mainScope(this, ev, 'Tick Value'); }, }; -Blockly.JavaScript.tick = () => ['Bot.getLastTick()', Blockly.JavaScript.ORDER_ATOMIC]; +Blockly.JavaScript.tick = () => ['Bot.getLastTick(false, false)', Blockly.JavaScript.ORDER_ATOMIC]; + +Blockly.Blocks.tick_string = { + init: function init() { + this.appendDummyInput().appendField(translate('Last Tick String')); + this.setOutput(true, 'Number'); + this.setColour('#f2f2f2'); + this.setTooltip(translate('Returns the tick value received by a before purchase block (String)')); + this.setHelpUrl('https://github.com/binary-com/binary-bot/wiki'); + }, + onchange: Blockly.Blocks.tick.onchange, +}; +Blockly.JavaScript.tick_string = () => ['Bot.getLastTick(false, true)', Blockly.JavaScript.ORDER_ATOMIC]; diff --git a/src/botPage/view/blockly/blocks/ticks/ticks.js b/src/botPage/view/blockly/blocks/ticks/ticks.js index e36cbf7230..54d126640d 100644 --- a/src/botPage/view/blockly/blocks/ticks/ticks.js +++ b/src/botPage/view/blockly/blocks/ticks/ticks.js @@ -14,4 +14,16 @@ Blockly.Blocks.ticks = { mainScope(this, ev, 'Ticks List'); }, }; -Blockly.JavaScript.ticks = () => ['Bot.getTicks()', Blockly.JavaScript.ORDER_ATOMIC]; +Blockly.JavaScript.ticks = () => ['Bot.getTicks(false)', Blockly.JavaScript.ORDER_ATOMIC]; + +Blockly.Blocks.ticks_string = { + init: function init() { + this.appendDummyInput().appendField(translate('Ticks String List')); + this.setOutput(true, 'Array'); + this.setColour('#f2f2f2'); + this.setTooltip(translate('Returns the list of tick values (String)')); + this.setHelpUrl('https://github.com/binary-com/binary-bot/wiki'); + }, + onchange: Blockly.Blocks.ticks.onchange, +}; +Blockly.JavaScript.ticks_string = () => ['Bot.getTicks(true)', Blockly.JavaScript.ORDER_ATOMIC]; diff --git a/src/botPage/view/logger.js b/src/botPage/view/logger.js index 2f419bf3f2..d74b800f26 100644 --- a/src/botPage/view/logger.js +++ b/src/botPage/view/logger.js @@ -37,6 +37,7 @@ const isNewError = isNewMessage(); const notify = ({ className, message, position = 'left', sound = 'silent' }) => { if (message && (position === 'left' || isNewNotification(message))) { log(className, message); + $.notify(message, { position: `bottom ${position}`, className }); if (sound !== 'silent') { $(`#${sound}`) diff --git a/static/xml/toolbox.xml b/static/xml/toolbox.xml index 16c6fe0a51..1e97c00722 100644 --- a/static/xml/toolbox.xml +++ b/static/xml/toolbox.xml @@ -281,6 +281,7 @@ + open @@ -300,6 +301,7 @@ +