Merge remote-tracking branch 'upstream/develop'

This commit is contained in:
Matias committed 2019-03-25 17:01:38 +01:00
commit d12a9d3ec3
10 files changed
+572 -869

No files matched your search

View File
File renamed without changes.
+3 -18
View File
@@ -60,13 +60,6 @@
internalLoopCounter++;
if (global.CURRENT_EXECUTION_AT === "Browser") {
//console.log("[INFO] DebugLog -> persist -> We do not persist logs while running at the Browser");
return;
}
let contentToPersist = accumulatedLog;
accumulatedLog = "[";
@@ -149,28 +142,20 @@
if (global.CURRENT_EXECUTION_AT === "IDE") {
console.log("AACloud" + spacePad(pModule, 50) + " : " + pMessage);
console.log("CloneExecutor" + spacePad(pModule, 50) + " : " + pMessage);
}
if (disableLogging === true) { return; }
if (global.CURRENT_EXECUTION_AT === "Browser") {
/* Only at the browser we send the messages to the console. At the Cloud it does not make sense. */
console.log("AACloud" + spacePad(pModule, 50) + " : " + pMessage);
return;
}
if (global.CURRENT_EXECUTION_AT === "Cloud") {
if (global.CURRENT_EXECUTION_AT === "Node") {
/* Only ERRORs go to the cloud console. */
if (pMessage.indexOf("[ERROR]") >= 0) {
let now = new Date;
console.log("Loop." + pad(thisObject.bot.loopCounter, 8) + " " + now.toUTCString() + " AACloud " + spacePad(pModule, 20) + " : " + pMessage);
console.log("Loop." + pad(thisObject.bot.loopCounter, 8) + " " + now.toUTCString() + " CloneExecutor " + spacePad(pModule, 20) + " : " + pMessage);
}
}
+2 -4
View File
@@ -38,16 +38,14 @@
let accessToken
let keyId
let cloneId
if (global.CURRENT_EXECUTION_AT === "Cloud") {
if (global.CURRENT_EXECUTION_AT === "Node") {
keyId = process.env.KEY_ID
cloneId = process.env.CLONE_ID
let auth = require('../utils/auth')
let authTokenCloud = await auth.authenticate()
accessToken = 'Bearer ' + authTokenCloud
} else if (global.CURRENT_EXECUTION_AT === "Browser") {
accessToken = 'Bearer ' + authToken
}
}
let keyVaultAPI = createKeyVaultAPIClient(accessToken, keyId, cloneId)
apiClient = api.newAPIClient(keyVaultAPI, logger);
+10 -65
View File
@@ -47,25 +47,11 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
let filePath;
switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy.
case "Cloud": {
if (global.RUN_AS_TEAM) {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud.
} else {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser.
}
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser.
break;
}
default: {
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'.");
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return; }
if (global.RUN_AS_TEAM) {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud.
} else {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser.
}
const CLOUD_REQUIRE = require(ROOT_DIR + 'CloudRequire');
@@ -84,23 +70,8 @@
USER_BOT_MODULE = pMODULE;
switch (global.CURRENT_EXECUTION_AT) {
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo;
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO;
break;
}
default: {
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'.");
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
}
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo;
cloudRequire.downloadCommons(cloudStorage, filePath, onCommonsDownloaded);
function onCommonsDownloaded(err, pMODULE) {
@@ -664,7 +635,7 @@
function checkLoopHealth(pLastLoop) {
if (global.CURRENT_EXECUTION_AT !== "Cloud") {
if (global.CURRENT_EXECUTION_AT !== "Node") {
return;
}
@@ -714,34 +685,8 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
let filePath;
switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy.
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud.
break;
}
case "Browser": {
if (global.SHALL_BOT_STOP === false) {
continueCallBack();
} else {
stopCallBack();
}
return;
}
default: {
logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'.");
logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT);
logger.persist();
clearInterval(fixedTimeLoopIntervalHandle);
clearTimeout(nextLoopTimeoutHandle);
clearTimeout(checkLoopHealthHandle);
bot.enableCheckLoopHealth = false;
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
}
let filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud.
let fileName = "this.config.json";
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
+8 -64
View File
@@ -50,25 +50,10 @@
let filePath;
switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy.
case "Cloud": {
if (global.RUN_AS_TEAM) {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud.
} else {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser.
}
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser.
break;
}
default: {
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'.");
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
if (global.RUN_AS_TEAM) {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud.
} else {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser.
}
const CLOUD_REQUIRE = require(ROOT_DIR + 'CloudRequire');
@@ -87,22 +72,7 @@
USER_BOT_MODULE = pMODULE;
switch (global.CURRENT_EXECUTION_AT) {
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo;
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO;
break;
}
default: {
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'.");
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
}
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo;
cloudRequire.downloadCommons(cloudStorage, filePath, onCommonsDownloaded);
@@ -898,7 +868,7 @@
function checkLoopHealth(pLastLoop) {
if (global.CURRENT_EXECUTION_AT !== "Cloud") {
if (global.CURRENT_EXECUTION_AT !== "Node") {
return;
}
@@ -948,34 +918,8 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
let filePath;
switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy.
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud.
break;
}
case "Browser": {
if (global.SHALL_BOT_STOP === false) {
continueCallBack();
} else {
stopCallBack();
}
return;
}
default: {
logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'.");
logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT);
logger.persist();
clearInterval(fixedTimeLoopIntervalHandle);
clearTimeout(nextLoopTimeoutHandle);
clearTimeout(checkLoopHealthHandle);
bot.enableCheckLoopHealth = false;
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
}
let filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud.
let fileName = "this.config.json";
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
+6 -4
View File
@@ -1,10 +1,12 @@
# AACloud
# Clone Executor
This repository holds the code of the bits of the AA Platform that run in the cloud.
Whithin the Superalgos project, we have the concept of Financial Beings, which are autonomous agents that have a financial life. These FBs entities have a master (imagine a class in programming) and clones (imagine an instance of a class running). The master is the one who aquires reputation after competitions. Every time we need to do a backtest, live trading or participating in a competition, a clone is extracted from the master and is put to run, either in backtest mode, live trading mode or competition mode. The clone lifespan is contrained by the purpose it was created. For instance, a clone created for a competition will live only during the period of such competition.
## About the AA Project
The software needed to execute these clones is the Clone Executor.
The AA Platform is built and maintained by Advanced Algos, the start up behind the AA Project.
## About the Superalgos Project
Superalgos is built and maintained by the Superalgos Foundation and its Community.
Our mission is to enable the fast-paced evolution of crypto trading bots within the context of trading bots competitions.
+529 -604
View File
File diff suppressed because it is too large. Load diff
+4 -4
View File
@@ -1,7 +1,7 @@
require('dotenv').config()
global.CURRENT_ENVIRONMENT = "Develop";
global.CURRENT_EXECUTION_AT = "Cloud";
global.CURRENT_EXECUTION_AT = "Node";
global.SHALL_BOT_STOP = false;
global.AT_BREAKPOINT = false; // This is used only when running at the browser.
global.RUN_AS_TEAM = false;
@@ -112,16 +112,16 @@ function readExecutionConfiguration() {
startMode[process.env.START_MODE].run = "true"
let executionList = [{
let cloneToExecute = {
enabled: "true",
devTeam: process.env.DEV_TEAM,
bot: process.env.BOT,
process: process.env.PROCESS,
repo: global.CURRENT_BOT_REPO
}]
}
global.EXECUTION_CONFIG = {
executionList: executionList,
cloneToExecute: cloneToExecute,
startMode: startMode,
timePeriod: getTimePeriod(process.env.TIME_PERIOD),
timePeriodFileStorage: process.env.TIME_PERIOD,
+10 -55
View File
@@ -52,7 +52,7 @@
let filePath;
switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy.
case "Cloud": {
case "Node": {
if (global.RUN_AS_TEAM) {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // DevTeams bots only are run at the cloud.
} else {
@@ -61,16 +61,12 @@
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO + "/" + pProcessConfig.name; // DevTeam Members bots only are run at the browser.
break;
}
case "IDE": {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo + "/" + pProcessConfig.name; // This works like Cloud except of a few things.
break;
}
default: {
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'.");
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Node' or 'IDE'.");
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
@@ -93,23 +89,8 @@
USER_BOT_MODULE = pMODULE;
switch (global.CURRENT_EXECUTION_AT) {
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo;
break;
}
case "Browser": {
filePath = global.DEV_TEAM + "/" + "members" + "/" + global.USER_LOGGED_IN + "/" + global.CURRENT_BOT_REPO;
break;
}
default: {
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'.");
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> onInizialized -> onBotDownloaded -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
}
filePath = global.DEV_TEAM + "/" + "bots" + "/" + bot.repo;
cloudRequire.downloadCommons(cloudStorage, filePath, onCommonsDownloaded);
function onCommonsDownloaded(err, pMODULE) {
@@ -284,7 +265,7 @@
}
if (global.CURRENT_EXECUTION_AT === "Cloud") {
if (global.CURRENT_EXECUTION_AT === "Node") {
if (bot.processDatetime.valueOf() > endDatetime.valueOf()) {
@@ -323,7 +304,7 @@
}
if (global.CURRENT_EXECUTION_AT === "Cloud") {
if (global.CURRENT_EXECUTION_AT === "Node") {
let beginDatetime = new Date(bot.competition.beginDatetime);
@@ -987,7 +968,7 @@
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> updateClonesModule -> Entering function."); }
if (global.CURRENT_EXECUTION_AT === "Cloud") {
if (global.CURRENT_EXECUTION_AT === "Node") {
// Update clones module with latest context informations
@@ -1079,7 +1060,7 @@
function checkLoopHealth(pLastLoop) {
if (global.CURRENT_EXECUTION_AT !== "Cloud") {
if (global.CURRENT_EXECUTION_AT !== "Node") {
return;
}
@@ -1131,34 +1112,8 @@
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
let filePath;
switch (global.CURRENT_EXECUTION_AT) { // This is what determines if the bot is loaded from the devTeam or an endUser copy.
case "Cloud": {
filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud.
break;
}
case "Browser": {
if (global.SHALL_BOT_STOP === false) {
continueCallBack();
} else {
stopCallBack();
}
return;
}
default: {
logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> CURRENT_EXECUTION_AT must be either 'Cloud' or 'Browser'.");
logger.write(MODULE_NAME, "[ERROR] run -> loop -> shallWeStop -> onInizialized -> global.CURRENT_EXECUTION_AT = " + global.CURRENT_EXECUTION_AT);
logger.persist();
clearInterval(fixedTimeLoopIntervalHandle);
clearTimeout(nextLoopTimeoutHandle);
clearTimeout(checkLoopHealthHandle);
bot.enableCheckLoopHealth = false;
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
}
let filePath = global.DEV_TEAM + "/" + "AACloud"; // DevTeams bots only are run at the cloud.
let fileName = "this.config.json";
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
-51
View File
@@ -5,57 +5,6 @@
"minor": 1,
"patch": 0
},
"executionList": [
{
"enabled": "false",
"devTeam": "AAMasters",
"bot": "AAMariam",
"process": "Trading-Process",
"repo": "AAMariam-Trading-Bot"
},
{
"enabled": "false",
"devTeam": "AAMasters",
"bot": "AACharly",
"process": "Poloniex-Live-Trades",
"repo": "AACharly-Extraction-Bot"
},
{
"enabled": "false",
"devTeam": "AAMasters",
"bot": "AACharly",
"process": "Poloniex-Hole-Fixing",
"repo": "AACharly-Extraction-Bot"
},
{
"enabled": "false",
"devTeam": "AAMasters",
"bot": "AABruce",
"process": "One-Min-Daily-Candles-Volumes",
"repo": "AABruce-Indicator-Bot"
},
{
"enabled": "false",
"devTeam": "AAMasters",
"bot": "AAOlivia",
"process": "Multi-Period-Daily",
"repo": "AAOlivia-Indicator-Bot"
},
{
"enabled": "false",
"devTeam": "AAMasters",
"bot": "AAOlivia",
"process": "Multi-Period-Market",
"repo": "AAOlivia-Indicator-Bot"
},
{
"enabled": "true",
"devTeam": "AAMasters",
"bot": "AAChris",
"process": "Multi-Period-Market",
"repo": "AAOlivia-Indicator-Bot"
}
],
"stopGracefully": false,
"marketRateProvider": {
"devTeam": "AAMasters",