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

Fixed many bugs and added many features #5

Merged
merged 9 commits into from
Jun 13, 2016
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
7 changes: 3 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ gulp.task('mocha', () => {
gulp.task('test', ['mocha'], function() {
return gulp.src(['./src/**/*.js', '!./src/**/*.min.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});

gulp.task('i18n-xml', ['static'], function () {
Expand Down Expand Up @@ -248,9 +249,7 @@ gulp.task('build-min', ['build-bot-min', 'build-index-min', 'pack-css-min', 'mus

gulp.task('deploy', ['build-min'], function () {
return gulp.src(['404.md', 'LICENSE', 'README.md', 'CNAME', './www/**'])
.pipe(ghPages({
branch: 'master'
}));
.pipe(ghPages());
});

gulp.task('serve', ['open', 'connect'], function () {
Expand Down
8 changes: 5 additions & 3 deletions src/bot/definitions/conditions/ticktrades.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#cur8so
// https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#zuc7w9
var blockly = require('blockly');
var i18n = require('i18n');
var config = require('../../globals/config');
Expand All @@ -10,13 +10,15 @@ Object.keys(config.opposites).forEach(function(opposites){
init: function() {
var option_names = [];
config.opposites[opposites].forEach(function(options){

var option_alias = Object.keys(options)[0];
var option_name = options[option_alias];
option_names.push(option_name);
});
this.appendDummyInput()
.appendField(option_names[0] + '/' + option_names[1]);
.setAlign(Blockly.ALIGN_CENTRE)
.appendField(utils.getCategoryName(opposites));
this.appendDummyInput()
.appendField('> ' + option_names[0] + '/' + option_names[1]);
this.appendValueInput("DURATION")
.setCheck("Number")
.appendField(i18n._("Ticks:"));
Expand Down
7 changes: 5 additions & 2 deletions src/bot/definitions/markets/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
// https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#abpy8a
// https://blockly-demo.appspot.com/static/demos/blockfactory/index.html#zr2375
var blockly = require('blockly');
var i18n = require('i18n');
var globals = require('../../globals/globals');
var botUtils = require('../../utils/utils');
var relationChecker = require('../../utils/relationChecker');
var symbolNames = globals.activeSymbols.getSymbolNames();
Object.keys(symbolNames).forEach(function(symbol){
blockly.Blocks[symbol.toLowerCase()] = {
init: function() {
this.appendDummyInput()
.appendField(symbolNames[symbol]);
this.appendDummyInput()
.appendField(i18n._('Accepts') + ': (' + botUtils.getAllowedCategoryNames(symbol) + ')');
this.appendStatementInput("CONDITION")
.setCheck("Condition");
this.setInputsInline(true);
this.setInputsInline(false);
this.setPreviousStatement(true, "Submarket");
this.setColour(345);
this.setTooltip(i18n._('Chooses the symbol:') + ' ' + symbolNames[symbol]);
Expand Down
24 changes: 14 additions & 10 deletions src/bot/globals/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ module.exports = {
[i18n._('Loss'), 'loss'],
],
CHECK_DIRECTION: [
[i18n._('Up'), 'up'],
[i18n._('Down'), 'down'],
[i18n._('Rise'), 'rise'],
[i18n._('Fall'), 'fall'],
[i18n._('No Change'), ''],
],
},

opposites: {
UPDOWN: [{
'CALL': i18n._('Up')
RISEFALL: [{
'CALL': i18n._('Rise')
}, {
'PUT': i18n._('Down')
'PUT': i18n._('Fall')
}],
ASIAN: [{
ASIANS: [{
'ASIANU': i18n._('Asian Up')
}, {
'ASIAND': i18n._('Asian Down')
Expand All @@ -61,15 +61,19 @@ module.exports = {
'DIGITUNDER': i18n._('Under')
}],
},

opposites_have_barrier: [
'MATCHESDIFFERS',
'OVERUNDER',
],
conditionsCategory: {
callput: ['updown'],
asian: ['asian'],
callput: ['risefall'],
asian: ['asians'],
digits: ['matchesdiffers', 'evenodd', 'overunder']
},
conditions: ['updown', 'asian', 'matchesdiffers', 'evenodd', 'overunder'],
conditionsCategoryName: {
callput: i18n._('Up/Down'),
asian: i18n._('Asians'),
digits: i18n._('Digits'),
},
conditions: ['risefall', 'asians', 'matchesdiffers', 'evenodd', 'overunder'],
};
2 changes: 2 additions & 0 deletions src/bot/tours/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ module.exports = {
started = true;
globals.tour = tour;
globals.tour.start();
return true;
}
}
return false;
},
stop: function stop() {
view.setOpacityForAll(true, 1);
Expand Down
4 changes: 2 additions & 2 deletions src/bot/trade/trade.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ var callStrategy = function callStrategy() {
if (ticks.length > 1) {
if (+ticks.slice(-1)[0].quote > +ticks.slice(-2)
.quote) {
direction = 'up';
direction = 'rise';
} else if (+ticks.slice(-1)[0].quote < +ticks.slice(-2)
.quote) {
direction = 'down';
direction = 'fall';
}
}
globals.on_strategy(+ticks.slice(-1)[0].quote, direction);
Expand Down
2 changes: 1 addition & 1 deletion src/bot/utils/__tests__/active_symbols.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/bot/utils/relationChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ var condition = function condition(_condition, ev, calledByParent) {
_condition.unplug();
} else if ( !botUtils.isConditionAllowedInSymbol(_condition.parentBlock_.type, _condition.type) ){
var symbol = botUtils.findSymbol(_condition.parentBlock_.type);
botUtils.log(symbol[Object.keys(symbol)[0]] + ' ' + i18n._('does not support this condition'), 'warning');
botUtils.log(symbol[Object.keys(symbol)[0]] + ' ' + i18n._('does not support category:') +
' ' + botUtils.getCategoryName(_condition.type) +
', ' + i18n._('Allowed categories are') + ' ' + botUtils.getAllowedCategoryNames(_condition.parentBlock_.type), 'warning');
_condition.unplug();
} else {
botUtils.broadcast('tour:condition');
Expand Down
42 changes: 39 additions & 3 deletions src/bot/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,56 @@ var commonUtils = require('utils');
var i18n = require('i18n');

var isConditionAllowedInSymbol = function isConditionAllowedInSymbol(symbol, condition) {
var allowedConditions = getAllowedConditions(symbol);
var allowedConditions = getAllowedConditions(symbol).conditions;
return allowedConditions.indexOf(condition) >= 0;
};

var getFirstObjectValue = function getFirstObjectValue(obj) {
return obj[Object.keys(obj)[0]];
};

var getConditionName = function getConditionName(condition) {
var opposites = config.opposites[condition.toUpperCase()];
return getFirstObjectValue(opposites[0]) + '/' + getFirstObjectValue(opposites[1]);
};

var getCategory = function getCategory(condition) {
for( var category in config.conditionsCategory ) {
if ( config.conditionsCategory[category].indexOf(condition.toLowerCase()) >= 0 ) {
return category;
}
}
};

var getCategoryName = function getCategoryName(condition) {
return config.conditionsCategoryName[getCategory(condition)];
};

var getAllowedCategoryNames = function getAllowedCategoryNames(symbol) {
var allowedCategories = getAllowedConditions(symbol).categories;
return allowedCategories.map(function(el){
return config.conditionsCategoryName[el];
});
};

var getAllowedConditions = function getAllowedConditions(symbol) {
var allowedConditions = [];
var allowedCategories = [];
globals.assetIndex.forEach(function(assetIndex){
if (assetIndex[0].toLowerCase() === symbol.toLowerCase()) {
assetIndex[2].forEach(function(conditionInfo){
var conditionName = conditionInfo[0];
if ( config.conditionsCategory.hasOwnProperty(conditionName) ) {
allowedConditions = allowedConditions.concat(config.conditionsCategory[conditionName]);
allowedCategories.push(conditionName);
}
});
}
});
return allowedConditions;
return {
conditions: allowedConditions,
categories: allowedCategories
};
};

var findSymbol = function findSymbol(symbol) {
Expand Down Expand Up @@ -320,5 +353,8 @@ module.exports = {
xmlToStr: xmlToStr,
findSymbol: findSymbol,
getAssetIndex: getAssetIndex,
isConditionAllowedInSymbol: isConditionAllowedInSymbol
isConditionAllowedInSymbol: isConditionAllowedInSymbol,
getAllowedCategoryNames: getAllowedCategoryNames,
getCategoryName: getCategoryName,
getConditionName: getConditionName
};
22 changes: 12 additions & 10 deletions src/bot/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ require('./utils/draggable');
var initTours = function initTours() {
tours.introduction = require('./tours/introduction').init();
tours.welcome = require('./tours/welcome').init();
tours.welcome.welcome();
if ( tours.welcome.welcome() ){
activeTutorial = tours.welcome;
$('#tutorialButton')
.unbind('click.startTutorial')
.bind('click.stopTutorial', stopTutorial)
.text(i18n._('Stop!'));
}
};

var uiComponents = {
Expand Down Expand Up @@ -53,10 +59,8 @@ var startTutorial = function startTutorial(e) {
.val()];
activeTutorial.start();
$('#tutorialButton')
.unbind('click', startTutorial);
$('#tutorialButton')
.bind('click', stopTutorial);
$('#tutorialButton')
.unbind('click.startTutorial')
.bind('click.stopTutorial', stopTutorial)
.text(i18n._('Stop!'));
};

Expand All @@ -71,10 +75,8 @@ var stopTutorial = function stopTutorial(e) {
activeTutorial = null;
}
$('#tutorialButton')
.unbind('click', stopTutorial);
$('#tutorialButton')
.bind('click', startTutorial);
$('#tutorialButton')
.unbind('click.stopTutorial')
.bind('click.startTutorial', startTutorial)
.text(i18n._('Go!'));
};

Expand Down Expand Up @@ -271,7 +273,7 @@ var show = function show(done) {
.addEventListener('change', handleFileSelect, false);

$('#tutorialButton')
.bind('click', startTutorial);
.bind('click.startTutorial', startTutorial);
$('#stopButton')
.text(i18n._('Reset'));
$('#stopButton')
Expand Down
6 changes: 3 additions & 3 deletions src/common/appId.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var utils = require('utils');

var AppId = {
app_id: ( document.location.port === '8080' ) ? 1168 : 1169,
app_id: ( document.location.port === '8080' ) ? 1168 : ( ( document.location.hostname.indexOf('github.io') >= 0 ) ? 1180 : 1169 ),
redirectOauth: function oauthLogin(){
document.location = 'https://oauth.binary.com/oauth2/authorize?app_id=' + this.app_id + '&l=' + window.lang.toUpperCase();
},
Expand All @@ -15,7 +15,7 @@ var AppId = {
});
if (tokenList.length) {
utils.addAllTokens(tokenList, function(){
document.location.pathname = '/bot.html';
document.location.pathname += ((document.location.pathname.slice(-1) === '/')?'':'/') + 'bot.html';
});
} else {
if (done) {
Expand All @@ -26,7 +26,7 @@ var AppId = {
removeTokenFromUrl: function removeTokenFromUrl(){
var queryStr = utils.parseQueryString();
if (queryStr.token1) {
document.location.search = '';
document.location.href = document.location.href.split('?')[0];
}
},
getAppId: function getAppId(){
Expand Down
16 changes: 11 additions & 5 deletions static/xml/toolbox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,17 @@
<category name="Binary" colour="60" i18n-text="Binary">
<!--Markets-->
<category name="Conditions" colour="15" i18n-text="Conditions">
<block type="updown"></block>
<block type="asian"></block>
<block type="matchesdiffers"></block>
<block type="evenodd"></block>
<block type="overunder"></block>
<category name="Up/Down" colour="15" i18n-text="Up/Down">
<block type="risefall"></block>
</category>
<category name="Asians" colour="15" i18n-text="Asians">
<block type="asians"></block>
</category>
<category name="Digits" colour="15" i18n-text="Digits">
<block type="matchesdiffers"></block>
<block type="evenodd"></block>
<block type="overunder"></block>
</category>
</category>
<category name="Strategy" colour="290" i18n-text="Strategy">
<block type="tick"></block>
Expand Down
2 changes: 1 addition & 1 deletion templates/bot.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{> bundle_css }}
</head>
<body id="drop_zone">
<div class="spinning"><img src="/image/binary-symbol-logo.svg"/></div>
<div class="spinning"><img src="image/binary-symbol-logo.svg"/></div>
<div id="center"></div>
<div class="toolbox">
<div class="intro-file-management">
Expand Down
2 changes: 1 addition & 1 deletion templates/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{> main_css }}
</head>
<body>
<div class="spinning"><img src="/image/binary-symbol-logo.svg"/></div>
<div class="spinning"><img src="image/binary-symbol-logo.svg"/></div>
<div id="header">
<div class="wrapper">
<a href="" id="logo">
Expand Down
6 changes: 3 additions & 3 deletions www/bot.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!DOCTYPE html>
<html>
<title>Binary Bot</title>
<link href="css/bot-2e120f8b0b.css" rel="stylesheet" /><link href="css/bundle-0a7eb16c40.css" rel="stylesheet" /></head>
<link href="css/bot-2e120f8b0b.css" rel="stylesheet" /><link href="css/bundle-385e16f73c.min.css" rel="stylesheet" /></head>
<body id="drop_zone">
<div class="spinning"><img src="/image/binary-symbol-logo.svg"/></div>
<div class="spinning"><img src="image/binary-symbol-logo.svg"/></div>
<div id="center"></div>
<div class="toolbox">
<div class="intro-file-management">
Expand Down Expand Up @@ -89,7 +89,7 @@ <h4>
</div>

<script src="js/blockly/blockly.js"></script>
<script src="js/bot-1257b21f0f2b1829540b.js"></script>
<script src="js/bot-4b60c2a902.min.js"></script>
</body>
</html>

5 changes: 5 additions & 0 deletions www/css/bundle-385e16f73c.min.css

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion www/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,15 @@
"837730f3669584a070e3252eccf39aa0b96d3820": "You can choose the token you want by the <b>Account</b> dropdown on the trade block. If you do not have any token in the dropdown please login using the <b>Login</b> button above. Please make sure to use Virtual Account tokens for testing.",
"362ade1b08d481c8c83c5dbc63866c81b4706814": "Welcome to the binary bot, a blockly based automation tool for binary.com trades. If you want to skip this tutorial click on the <b>Stop!</b> button at the top right of the page.",
"da9f5de675878c0d60438194c913be6be8442451": "Welcome to the introduction to the binary bot, we will go through the basic steps to create a working bot. If you want to skip this tutorial click on the <b>Stop!</b> button at the top right of the page.",
"34dae9390583a6d4bba3b71c5929df4fe4d985b0": "does not support this condition"
"34dae9390583a6d4bba3b71c5929df4fe4d985b0": "does not support this condition",
"30de51af8df6b6a7f6b6d26a113fa5e2eea54415": "Accepts",
"563339f82447b4e758ad76d5a0b63b5698594fba": "Rise",
"5c1ae82c29543ac887703776bf3da2c7dcce683d": "Fall",
"f94510322ecd9b3a2af67a10bd51ecc4ac6a24e7": "Up/Down",
"9c7960c6b11d35ac9d6cdc1ebaad3af43b2065c5": "Asians",
"2260ce49306460c8a2ef501939f29ad6ddd4e934": "Digits",
"73d80ed0f64f5ce97460a01f3eb0fe660b37ea7a": "does not support condition:",
"14e44f34585c54b478925a93690cf9760a92d3df": "Allowed are",
"b3214afd299cfa3952efc8d8853c7b5a7f340405": "does not support category:",
"4166e06fcdc703410a1edb28a7bcea9ed0a4bfdb": "Allowed categories are"
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy