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
4 changes: 2 additions & 2 deletions src/botPage/bot/Interface/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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) {
Expand Down
32 changes: 22 additions & 10 deletions src/botPage/bot/TradeEngine/Ticks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion src/botPage/bot/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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),
];
};

Expand Down
2 changes: 2 additions & 0 deletions src/botPage/common/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
],
Expand Down
4 changes: 2 additions & 2 deletions src/botPage/view/TradeInfoPanel/TradeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
14 changes: 13 additions & 1 deletion src/botPage/view/blockly/blocks/ticks/tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
14 changes: 13 additions & 1 deletion src/botPage/view/blockly/blocks/ticks/ticks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
1 change: 1 addition & 0 deletions src/botPage/view/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down
2 changes: 2 additions & 0 deletions static/xml/toolbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@
<category name="Tick Analysis" i18n-text="Tick Analysis">
<block type="tick_analysis"></block>
<block type="tick"></block>
<block type="tick_string"></block>
<block type="last_digit"></block>
<block type="read_ohlc">
<field name="OHLCFIELD_LIST">open</field>
Expand All @@ -300,6 +301,7 @@
</value>
</block>
<block type="ticks"></block>
<block type="ticks_string"></block>
<block type="lastDigitList"></block>
<block type="ohlc"></block>
<block type="ohlc_values"></block>
Expand Down