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
Show all changes
73 commits
Select commit Hold shift + click to select a range
7d715f0
misc block error
Jun 20, 2019
103a421
change method
Jun 20, 2019
54e960c
Merge branch 'dev' into misc-blocks
sam-binary Jun 20, 2019
1aa7da0
contract notify pip size
Jun 25, 2019
276e125
resolve changes
Jun 25, 2019
c8281ec
eslint
Jun 25, 2019
01094af
Merge branch 'dev' into misc-blocks
sam-binary Jun 25, 2019
4719026
last tick string & tick list string
Jun 26, 2019
9b9484f
add entrytick string & exittick string
Jun 26, 2019
0064649
Merge branch 'dev' into contract-pip-size
sam-binary Jun 26, 2019
faf296a
load default start
Jun 27, 2019
e6e77d6
Merge branch 'dev' into contract-pip-size
sam-binary Jun 27, 2019
12acfc0
blockly es6 not support
Jun 27, 2019
0bc032d
Merge branch 'dev' into misc-blocks
sam-binary Jun 27, 2019
4a1ae30
resolve changes
Jun 27, 2019
95f47c4
changes
Jun 27, 2019
9bb514f
add strat file
Jun 27, 2019
d90fb05
Merge branch 'dev' into marketing-strategy
sam-binary Jun 27, 2019
6b28d53
fix target blocks unplug in define trade options
Jun 28, 2019
42b39d7
fix null error
Jun 28, 2019
ce39c3e
total profit decimal place
Jun 28, 2019
ad6bb0c
jest
Jun 28, 2019
60908ae
Merge branch 'dev' into decimal-missing
sam-binary Jun 28, 2019
64fa330
resolve changes
Jun 28, 2019
44a327e
fix no feeback on same xml import
Jul 1, 2019
068a1b8
Merge branch 'dev' into same-xml
sam-binary Jul 1, 2019
0389fc9
Merge branch 'dev' into same-xml
Jul 1, 2019
2fac50f
remove comment
Jul 1, 2019
48c7fcb
Merge branch 'dev' into misc-blocks
sam-binary Jul 1, 2019
988b853
travis timeout fix
Jul 2, 2019
48f1099
Merge branch 'dev' into travis-timeout
sam-binary Jul 2, 2019
3266cd5
new string
Jul 2, 2019
61dead5
Merge branch 'dev' into new-string
sam-binary Jul 2, 2019
3dfc007
Merge branch 'dev' into travis-timeout
Jul 3, 2019
fbd4692
Merge pull request #1647 from sam-binary/travis-timeout
Jul 3, 2019
2c34a88
Update stale.yml
Jul 4, 2019
7133025
hide notify when profit is zero
Jul 4, 2019
cb4c243
Merge branch 'dev' into decimal-missing
sam-binary Jul 4, 2019
d39404f
Merge pull request #1666 from binary-com/patch-stale-1
Jul 5, 2019
0f48048
adjust tradetable entryvalue & exitvalue width
Jul 5, 2019
bab49bf
Merge branch 'dev' into contract-pip-size
sam-binary Jul 5, 2019
4a95a85
new string
Jul 5, 2019
4855968
Merge branch 'dev' into new-string
sam-binary Jul 5, 2019
c6b1e99
Update src/botPage/bot/Interface/MiscInterface.js
sam-binary Jul 5, 2019
d941928
Merge branch 'dev' into decimal-missing
sam-binary Jul 5, 2019
9c787ec
eslint
Jul 5, 2019
6d5521d
Merge pull request #1650 from sam-binary/new-string
Jul 5, 2019
10a184f
Merge branch 'dev' into contract-pip-size
Jul 5, 2019
7a690d6
Merge branch 'dev' into decimal-missing
Jul 8, 2019
6dd49cd
Create global state in observer
Jul 9, 2019
db5793f
Keep track of bot is_running status globally
Jul 9, 2019
e3b33a5
Ensure correct button status
Jul 9, 2019
4363e58
Refactor disableRunButton function
Jul 9, 2019
30a3982
fix trade panel width
Jul 9, 2019
3e5141f
Restore display on stopBeforeStart
Jul 9, 2019
7e02356
Convert everything to camelCase
Jul 9, 2019
9ee2b50
Don't manipulate passed argument directly
Jul 9, 2019
db544b8
Set #summaryStopButton to display: none by default
Jul 9, 2019
497e92b
Be consistent in display values
Jul 9, 2019
9a9a864
aaronint
Jul 9, 2019
29af92f
Merge pull request #1693 from aaron-binary/running-indicator
ashkanx Jul 16, 2019
e41ca28
Merge branch 'dev' into contract-pip-size
ashkanx Jul 16, 2019
c1ea1b4
Merge pull request #1629 from sam-binary/contract-pip-size
ashkanx Jul 16, 2019
bb9d164
Merge branch 'dev' into trade-info-panel
ashkanx Jul 16, 2019
dbe7c3c
Merge pull request #1692 from sam-binary/trade-info-panel
ashkanx Jul 16, 2019
d47b1ab
Merge branch 'dev' into misc-blocks
ashkanx Jul 16, 2019
be74d83
Merge pull request #1622 from sam-binary/misc-blocks
ashkanx Jul 16, 2019
7291488
Merge branch 'dev' into marketing-strategy
ashkanx Jul 16, 2019
3356d2b
Merge pull request #1634 from sam-binary/marketing-strategy
ashkanx Jul 16, 2019
b9b5bde
Merge branch 'dev' into decimal-missing
ashkanx Jul 16, 2019
d3669d5
Merge pull request #1638 from sam-binary/decimal-missing
ashkanx Jul 16, 2019
e301ced
Merge branch 'dev' into same-xml
ashkanx Jul 16, 2019
99490d1
Merge pull request #1645 from sam-binary/same-xml
ashkanx Jul 16, 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
7 changes: 6 additions & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ daysUntilClose: 14
exemptLabels:
- bug
- "technical issues"
- "feature request"


# Label to use when marking an issue as stale
staleLabel: stale

# Comment to post when marking as stale. Set to `false` to disable
markComment: false
Expand All @@ -21,4 +26,4 @@ closeComment: >
any recent activity. Please open a new issue for related bugs.

# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30
limitPerRun: 30
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ install: npm ci
cache:
directories:
- node_modules
script: travis_retry npm test
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),
};
}
};
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
4 changes: 3 additions & 1 deletion src/botPage/bot/Interpreter.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ export default class Interpreter {
}
terminateSession() {
this.$scope.api.disconnect();
globalObserver.emit('bot.stop');
this.stopped = true;

globalObserver.emit('bot.stop');
globalObserver.setState({ isRunning: false });
}
stop() {
if (this.bot.tradeEngine.isSold === false && !this.isErrorTriggered) {
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
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
1 change: 1 addition & 0 deletions src/botPage/bot/TradeEngine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default class TradeEngine extends Balance(Purchase(Sell(OpenContract(Prop
}

globalObserver.emit('bot.running');
globalObserver.setState({ isRunning: true });

this.tradeOptions = expectTradeOptions(tradeOptions);

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
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
66 changes: 50 additions & 16 deletions src/botPage/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export default class View {
globalObserver.emit('ui.log.info', `${translate('File is not supported:')} ${file.name}`);
}
});
$('#files').val('');
};

const handleDragOver = e => {
Expand Down Expand Up @@ -455,7 +456,9 @@ export default class View {
};

const showSummary = () => {
$('#summaryPanel').dialog('open');
$('#summaryPanel')
.dialog('option', 'minWidth', 770)
.dialog('open');
addExportButtonToPanel('summaryPanel');
};

Expand Down Expand Up @@ -511,11 +514,19 @@ export default class View {
});

const startBot = limitations => {
const $runButtons = $('#runButton, #summaryRunButton');
const $stopButtons = $('#stopButton, #summaryStopButton');
$stopButtons.show();
$runButtons.hide();
$runButtons.prop('disabled', true);
const elRunButtons = document.querySelectorAll('#runButton, #summaryRunButton');
const elStopButtons = document.querySelectorAll('#stopButton, #summaryStopButton');

elRunButtons.forEach(el => {
const elRunButton = el;
elRunButton.style.display = 'none';
elRunButton.setAttributeNode(document.createAttribute('disabled'));
});
elStopButtons.forEach(el => {
const elStopButton = el;
elStopButton.style.display = 'inline-block';
});

globalObserver.emit('summary.disable_clear');
showSummary();
this.blockly.run(limitations);
Expand Down Expand Up @@ -627,31 +638,54 @@ export default class View {
this.blockly.stop();
}
addEventHandlers() {
const getRunButtonElements = () => document.querySelectorAll('#runButton, #summaryRunButton');
const getStopButtonElements = () => document.querySelectorAll('#stopButton, #summaryStopButton');

window.addEventListener('storage', e => {
window.onbeforeunload = null;
if (e.key === 'activeToken' && !e.newValue) window.location.reload();
if (e.key === 'realityCheckTime') hideRealityCheck();
});

globalObserver.register('Error', error => {
$('#runButton, #summaryRunButton').prop('disabled', false);
getRunButtonElements().forEach(el => {
const elRunButton = el;
elRunButton.removeAttribute('disabled');
});

if (error.error && error.error.error.code === 'InvalidToken') {
removeAllTokens();
updateTokenList();
this.stop();
}
});

globalObserver.register('bot.running', () => {
getRunButtonElements().forEach(el => {
const elRunButton = el;
elRunButton.style.display = 'none';
elRunButton.setAttributeNode(document.createAttribute('disabled'));
});
getStopButtonElements().forEach(el => {
const elStopButton = el;
elStopButton.style.display = 'inline-block';
elStopButton.removeAttribute('disabled');
});
});

globalObserver.register('bot.stop', () => {
const $runButtons = $('#runButton, #summaryRunButton');
const $stopButtons = $('#stopButton, #summaryStopButton');
if ($runButtons.is(':visible') || $stopButtons.is(':visible')) {
$runButtons.show();
$stopButtons.hide();

$stopButtons.prop('disabled', false);
$runButtons.prop('disabled', false);
}
// Enable run button, this event is emitted after the interpreter
// killed the API connection.
getStopButtonElements().forEach(el => {
const elStopButton = el;
elStopButton.style.display = null;
elStopButton.removeAttribute('disabled');
});
getRunButtonElements().forEach(el => {
const elRunButton = el;
elRunButton.style.display = null;
elRunButton.removeAttribute('disabled');
});
});

globalObserver.register('bot.info', info => {
Expand Down
19 changes: 17 additions & 2 deletions src/botPage/view/blockly/blocks/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,21 @@ export const getPredictionForContracts = (contracts, selectedContractType) => {
return predictionRange;
};

export const disableRunButton = isDisabled => {
$('#runButton, #summaryRunButton').attr('disabled', isDisabled);
export const disableRunButton = shouldDisable => {
const elRunButtons = document.querySelectorAll('#runButton, #summaryRunButton');
const isRunning = globalObserver.getState('isRunning');

elRunButtons.forEach(elRunButton => {
if (isRunning) {
if (shouldDisable) {
elRunButton.setAttributeNode(document.createAttribute('disabled'));
} else {
// Do not enable. The bot is running.
}
} else if (shouldDisable) {
elRunButton.setAttributeNode(document.createAttribute('disabled'));
} else {
elRunButton.removeAttribute('disabled');
}
});
};
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];
26 changes: 25 additions & 1 deletion src/botPage/view/blockly/blocks/tools/total_profit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,29 @@ Blockly.Blocks.total_profit = {
this.setTooltip(translate('Returns the total profit'));
this.setHelpUrl('https://github.com/binary-com/binary-bot/wiki');
},
onchange: function onchange(ev) {
if (!this.workspace || this.isInFlyout || this.workspace.isDragging()) {
return;
}

if (ev.type === Blockly.Events.MOVE) {
const inputStatement = this.getRootInputTargetBlock();

if (inputStatement === 'INITIALIZATION') {
this.unplug(true);
}
}
},
};
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 = () => ['Bot.getTotalProfit()', Blockly.JavaScript.ORDER_ATOMIC];
Blockly.JavaScript.total_profit_string = () => ['Bot.getTotalProfit(true)', Blockly.JavaScript.ORDER_ATOMIC];
Loading