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

Staging #1606

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
73fd108
Fix isNewTradeOption method by checking unit + symbol
May 27, 2019
99c950d
Merge pull request #1549 from aaron-binary/duration-options-bug
ashkanx May 28, 2019
394d95a
Display buy_price with decimals
May 29, 2019
531a5d7
Show correct decimals for balance
May 31, 2019
7468398
Merge pull request #1558 from aaron-binary/total-balance-incorrectly-…
ashkanx Jun 4, 2019
6a036a4
remove duplicate block
Jun 10, 2019
e71724d
Merge pull request #1576 from sam-binary/removing-duplicate-block
Jun 10, 2019
29145ae
Merge branch 'dev' of github.com:Khalidxx/binary-bot into dev
khalidibrahimio Jun 10, 2019
6295544
Merge branch 'dev' of github.com:binary-com/binary-bot into dev
khalidibrahimio Jun 10, 2019
c20552d
added range of ticks
khalidibrahimio Jun 10, 2019
65717ff
Merge branch 'dev' of github.com:binary-com/binary-bot into data-coer…
Jun 11, 2019
c7c51d1
Ensure entry_tick + exit_tick are displayed correctly
Jun 11, 2019
c64c0b2
Merge pull request #1577 from Khalidxx/default-ticks
Jun 11, 2019
0be1578
Show correct # decimals for buy_price
Jun 11, 2019
b33efae
Pass proposal + currency to contractStatus for correct display of values
Jun 11, 2019
825cd7e
tooltip-misalignment
Jun 11, 2019
d6db46a
Merge branch 'dev' into data-coercion
ashkanx Jun 11, 2019
925d273
Merge pull request #1553 from aaron-binary/data-coercion
ashkanx Jun 11, 2019
4756300
Merge branch 'dev' into tooltip-misalignment
sam-binary Jun 11, 2019
ee5ab2e
fix extra space between rectangle and narrow
Jun 12, 2019
eaa364a
fix space between triangle & box
Jun 12, 2019
3705eb0
fix space between triangle & textbox
Jun 12, 2019
697054c
fix space between triangle and box
Jun 12, 2019
c60f91d
The play() request was interrupted by a call to pause().
Jun 12, 2019
44f87f1
Merge branch 'dev' into trackjs-audio
sam-binary Jun 12, 2019
b3cc10c
disable trackjs for non-production domain
Jun 12, 2019
74ff06d
Merge branch 'dev' into illegal-break-statement
sam-binary Jun 12, 2019
c58d78a
Merge pull request #1589 from sam-binary/trackjs-audio
ashkanx Jun 13, 2019
b22b46d
Merge branch 'dev' into illegal-break-statement
ashkanx Jun 13, 2019
d07695c
Merge pull request #1590 from sam-binary/illegal-break-statement
ashkanx Jun 13, 2019
9478391
Merge branch 'dev' into tooltip-misalignment
ashkanx Jun 13, 2019
d4d8587
Merge pull request #1587 from sam-binary/tooltip-misalignment
ashkanx Jun 13, 2019
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
8 changes: 5 additions & 3 deletions src/botPage/bot/TradeEngine/Proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default Engine =>
}

return {
id : toBuy.id,
askPrice: toBuy.ask_price,
proposal: toBuy,
currency: this.tradeOption.currency,
};
}
renewProposalsOnPurchase() {
Expand Down Expand Up @@ -138,10 +138,12 @@ export default Engine =>

return (
isNotEqual('duration') ||
isNotEqual('duration_unit') ||
isNotEqual('amount') ||
isNotEqual('prediction') ||
isNotEqual('barrierOffset') ||
isNotEqual('secondBarrierOffset')
isNotEqual('secondBarrierOffset') ||
isNotEqual('symbol')
);
}
};
17 changes: 13 additions & 4 deletions src/botPage/bot/TradeEngine/Purchase.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@ export default Engine =>
return Promise.resolve();
}

const { id, askPrice } = this.selectProposal(contractType);

const { currency, proposal } = this.selectProposal(contractType);
const onSuccess = r => {
const { buy } = r;

contractStatus({
id : 'contract.purchase_recieved',
data: buy.transaction_id,
proposal,
currency,
});

this.subscribeToOpenContract(buy.contract_id);
this.store.dispatch(purchaseSuccessful());
this.renewProposalsOnPurchase();

delayIndex = 0;

notify('info', `${translate('Bought')}: ${buy.longcode} (${translate('ID')}: ${buy.transaction_id})`);

info({
accountID : this.accountInfo.loginid,
totalRuns : this.updateAndReturnTotalRuns(),
Expand All @@ -37,13 +42,17 @@ export default Engine =>
});
};

const action = () => this.api.buyContract(id, askPrice);
this.isSold = false;

contractStatus({
id : 'contract.purchase_sent',
data: askPrice,
data: proposal.ask_price,
proposal,
currency,
});

const action = () => this.api.buyContract(proposal.id, proposal.ask_price);

if (!this.options.timeMachineEnabled) {
return doUntilDone(action).then(onSuccess);
}
Expand Down
132 changes: 83 additions & 49 deletions src/botPage/view/TradeInfoPanel/TradeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import json2csv from 'json2csv';
import React, { Component } from 'react';
import ReactDataGrid from 'react-data-grid';
import { observer as globalObserver } from '../../../common/utils/observer';
import { appendRow, updateRow, saveAs } from '../shared';
import { appendRow, updateRow, saveAs, ticksService } from '../shared';
import { translate } from '../../../common/i18n';
import { roundBalance } from '../../common/tools';
import * as style from '../style';
Expand Down Expand Up @@ -57,6 +57,27 @@ export default class TradeTable extends Component {
{ key: 'contract_status', width: 70, resizable: true, name: translate('Status'), formatter: StatusFormat },
];
}

static getTradeObject(pipSizes, contract) {
const symbolPipSize = pipSizes[contract.underlying];
const tradeObj = {
...contract,
reference: `${contract.transaction_ids.buy}`,
buy_price: roundBalance({ balance: contract.buy_price, currency: contract.currency }),
timestamp: getTimestamp(contract.date_start),
};

if (contract.entry_tick) {
tradeObj.entry_tick = (+contract.entry_tick).toFixed(symbolPipSize);
}

if (contract.exit_tick) {
tradeObj.exit_tick = (+contract.exit_tick).toFixed(symbolPipSize);
}

return tradeObj;
}

componentWillMount() {
const { api } = this.props;

Expand All @@ -66,44 +87,50 @@ export default class TradeTable extends Component {
this.export();
}
});

globalObserver.register('summary.clear', () => {
this.setState({ [this.props.accountID]: { ...this.state.initial } });
globalObserver.emit('summary.disable_clear');
});

globalObserver.register('bot.stop', () => {
const accountData = this.state[this.props.accountID];
if (accountData && accountData.rows.length > 0) {
globalObserver.emit('summary.enable_clear');
}
});
globalObserver.register('bot.contract', info => {
if (!info) {

globalObserver.register('bot.contract', contract => {
if (!contract) {
return;
}
const timestamp = getTimestamp(info.date_start);
const tradeObj = { reference: info.transaction_ids.buy, ...info, timestamp };
const { accountID } = tradeObj;

const trade = {
...tradeObj,
profit : getProfit(tradeObj),
contract_status : translate('Pending'),
contract_settled: false,
};

const accountStat = this.getAccountStat(accountID);

const { rows } = accountStat;
const prevRowIndex = rows.findIndex(t => t.reference === trade.reference);

if (trade.is_expired && trade.is_sold && !trade.exit_tick) trade.exit_tick = '-';
ticksService.requestPipSizes().then(pipSizes => {
const tradeObj = TradeTable.getTradeObject(pipSizes, contract);
const trade = {
...tradeObj,
profit : getProfit(tradeObj),
contract_status : translate('Pending'),
contract_settled: false,
};

const { accountID } = tradeObj;
const accountStat = this.getAccountStat(accountID);
const { rows } = accountStat;
const prevRowIndex = rows.findIndex(t => t.reference === trade.reference);

if (trade.is_expired && trade.is_sold && !trade.exit_tick) {
trade.exit_tick = '-';
}

if (prevRowIndex >= 0) {
this.setState({ [accountID]: updateRow(prevRowIndex, trade, accountStat) });
} else {
this.setState({ [accountID]: appendRow(trade, accountStat) });
}
if (prevRowIndex >= 0) {
this.setState({ [accountID]: updateRow(prevRowIndex, trade, accountStat) });
} else {
this.setState({ [accountID]: appendRow(trade, accountStat) });
}
});
});

globalObserver.register('contract.settled', contract => {
const contractID = contract.contract_id;
this.settleContract(api, contractID);
Expand Down Expand Up @@ -139,40 +166,47 @@ export default class TradeTable extends Component {

refreshContract(api, contractID) {
return api.getContractInfo(contractID).then(r => {
const contract = r.proposal_open_contract;
const timestamp = getTimestamp(contract.date_start);
const tradeObj = { reference: contract.transaction_ids.buy, ...contract, timestamp };
const { accountID } = this.props;

const trade = {
...tradeObj,
profit: getProfit(tradeObj),
};

if (trade.is_expired && trade.is_sold && !trade.exit_tick) trade.exit_tick = '-';

const { id } = this.state[accountID];
const rows = this.state[accountID].rows.slice();
const updatedRows = rows.map(row => {
const { reference } = row;
if (reference === trade.reference) {
return {
contract_status : translate('Settled'),
contract_settled: true,
reference,
...trade,
};
ticksService.requestPipSizes().then(pipSizes => {
const contract = r.proposal_open_contract;
const tradeObj = TradeTable.getTradeObject(pipSizes, contract);
const trade = {
...tradeObj,
profit: getProfit(tradeObj),
};

if (trade.is_expired && trade.is_sold && !trade.exit_tick) {
trade.exit_tick = '-';
}
return row;

const { accountID } = this.props;
const { id } = this.state[accountID];
const rows = this.state[accountID].rows.slice();

const updatedRows = rows.map(row => {
const { reference } = row;

if (reference === trade.reference) {
return {
contract_status : translate('Settled'),
contract_settled: true,
reference,
...trade,
};
}
return row;
});

this.setState({ [accountID]: { id, rows: updatedRows } });
});
this.setState({ [accountID]: { id, rows: updatedRows } });
});
}

rowGetter(i) {
const { accountID } = this.props;
const { rows } = this.state[accountID];
return rows[rows.length - 1 - i];
}

export() {
const { accountID } = this.props;

Expand Down
11 changes: 10 additions & 1 deletion src/botPage/view/TradeInfoPanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Summary from './Summary';
import TradeTable from './TradeTable';
import RunButton from './RunButton';
import ClearButton from './ClearButton';
import { roundBalance } from '../../common/tools';

const resetAnimation = () => {
$('.circle-wrapper')
Expand Down Expand Up @@ -71,7 +72,14 @@ class AnimateTrade extends Component {
if (contractStatus.id === 'contract.purchase_sent') {
resetAnimation();
activateStage(0);
this.setState({ buy_price: contractStatus.data, stopMessage: this.indicatorMessages.stopping });

this.setState({
buy_price: roundBalance({
balance : contractStatus.proposal.ask_price,
currency: contractStatus.currency,
}),
stopMessage: this.indicatorMessages.stopping,
});
} else if (contractStatus.id === 'contract.purchase_recieved') {
$('.line').addClass('active');
activateStage(1);
Expand All @@ -81,6 +89,7 @@ class AnimateTrade extends Component {
activateStage(2);
this.setState({ sell_id: contractStatus.data, stopMessage: this.indicatorMessages.stopped });
}

activateStage(contractStatus.id);
}
render() {
Expand Down
16 changes: 12 additions & 4 deletions src/botPage/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import Tour from './tour';
import TradeInfoPanel from './TradeInfoPanel';
import { showDialog } from '../bot/tools';
import Elevio from '../../common/elevio';
import { updateConfigCurrencies } from '../common/const';
import { roundBalance, isVirtual } from '../common/tools';
import config, { updateConfigCurrencies } from '../common/const';
import { isVirtual } from '../common/tools';
import {
logoutAllTokens,
getOAuthURL,
Expand Down Expand Up @@ -66,8 +66,16 @@ api.events.on('balance', response => {
balance: { balance: b, currency },
} = response;

const balance = (+roundBalance({ currency, balance: b })).toLocaleString(getLanguage().replace('_', '-'));
$('.topMenuBalance').text(`${balance} ${currency}`);
const elTopMenuBalances = document.querySelectorAll('.topMenuBalance');
const localString = getLanguage().replace('_', '-');
const balance = (+b).toLocaleString(localString, {
minimumFractionDigits: config.lists.CRYPTO_CURRENCIES.includes(currency) ? 8 : 2,
});

elTopMenuBalances.forEach(elTopMenuBalance => {
const element = elTopMenuBalance;
element.textContent = `${balance} ${currency}`;
});
});

const addBalanceForToken = token => {
Expand Down
2 changes: 1 addition & 1 deletion src/botPage/view/blockly/blocks/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export const getPredictionForContracts = (contracts, selectedContractType) => {
if (contract && contract.last_digit_range) {
predictionRange.push(...contract.last_digit_range);
} else {
predictionRange.push(0);
predictionRange.push(1, 2, 3, 4, 5);
}
}
return predictionRange;
Expand Down
18 changes: 18 additions & 0 deletions src/botPage/view/blockly/customBlockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,21 @@ Blockly.Toolbox.TreeNode.prototype.onClick_ = function(_e) {
}
this.updateRow();
};

/**
* Preload all the audio files so that they play quickly when asked for.
* @package
*/
Blockly.WorkspaceAudio.prototype.preload = function() {
for (var name in this.SOUNDS_) {
var sound = this.SOUNDS_[name];
sound.volume = 0.01;
sound.play().catch(function() {});
sound.pause();
// iOS can only process one sound at a time. Trying to load more than one
// corrupts the earlier ones. Just load one and leave the others uncached.
if (goog.userAgent.IPAD || goog.userAgent.IPHONE) {
break;
}
}
};
3 changes: 2 additions & 1 deletion src/botPage/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import View from './View';
import '../../common/binary-ui/dropdown';
import Elevio from '../../common/elevio';
import GTM from '../../common/gtm';
import { isProduction } from '../../common/utils/tools';

$.ajaxSetup({
cache: false,
Expand All @@ -14,7 +15,7 @@ $.ajaxSetup({
window._trackJs = {
token : '346262e7ffef497d85874322fff3bbf8',
application: 'binary-bot',
enabled : window.location.hostname !== 'localhost',
enabled : isProduction(),
console : {
display: false,
},
Expand Down
Loading