Adding env variables and fixing issues
This commit is contained in:
1 parent
b8f655d1ba
commit
f58a9f76a5
8 files changed
+45
-62
No files matched your search
+5
-40
@@ -918,10 +918,6 @@
|
||||
|
||||
try {
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] putPosition -> Entering function."); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] putPosition -> pType = " + pType); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] putPosition -> pRate = " + pRate); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] putPosition -> pAmountA = " + pAmountA); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] putPosition -> pAmountB = " + pAmountB); }
|
||||
|
||||
/* Removing extra decimals. */
|
||||
|
||||
@@ -929,6 +925,11 @@
|
||||
pAmountA = thisObject.truncDecimals(pAmountA);
|
||||
pAmountB = thisObject.truncDecimals(pAmountB);
|
||||
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] putPosition -> pType = " + pType); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] putPosition -> pRate = " + pRate); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] putPosition -> pAmountA = " + pAmountA); }
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] putPosition -> pAmountB = " + pAmountB); }
|
||||
|
||||
/* Validations that the limits are not surpassed. */
|
||||
|
||||
if (pType === 'buy') {
|
||||
@@ -947,24 +948,6 @@
|
||||
callBackFunction(err);
|
||||
return;
|
||||
}
|
||||
|
||||
let aRate = thisObject.truncDecimals(pAmountA / pRate);
|
||||
|
||||
if (aRate !== pAmountB) {
|
||||
|
||||
logger.write(MODULE_NAME, "[ERROR] putPosition -> Input Validations -> pAmountA / pRate !== pAmountB.");
|
||||
logger.write(MODULE_NAME, "[ERROR] putPosition -> Input Validations -> pAmountA = " + pAmountA);
|
||||
logger.write(MODULE_NAME, "[ERROR] putPosition -> Input Validations -> pAmountB = " + pAmountB);
|
||||
logger.write(MODULE_NAME, "[ERROR] putPosition -> Input Validations -> pRate = " + pRate);
|
||||
|
||||
let err = {
|
||||
result: global.DEFAULT_FAIL_RESPONSE.result,
|
||||
message: 'pAmountB * pRate !== pAmountA'
|
||||
};
|
||||
|
||||
callBackFunction(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (pType === 'sell') {
|
||||
@@ -983,24 +966,6 @@
|
||||
callBackFunction(err);
|
||||
return;
|
||||
}
|
||||
|
||||
let bRate = thisObject.truncDecimals(pAmountB * pRate);
|
||||
|
||||
if (bRate !== pAmountA) {
|
||||
|
||||
logger.write(MODULE_NAME, "[ERROR] putPosition -> Input Validations -> pAmountB * pRate !== pAmountA.");
|
||||
logger.write(MODULE_NAME, "[ERROR] putPosition -> Input Validations -> pAmountA = " + pAmountA);
|
||||
logger.write(MODULE_NAME, "[ERROR] putPosition -> Input Validations -> pAmountB = " + pAmountB);
|
||||
logger.write(MODULE_NAME, "[ERROR] putPosition -> Input Validations -> pRate = " + pRate);
|
||||
|
||||
let err = {
|
||||
result: global.DEFAULT_FAIL_RESPONSE.result,
|
||||
message: 'pAmountB * pRate !== pAmountA'
|
||||
};
|
||||
|
||||
callBackFunction(err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* All validations passed, we proceed. */
|
||||
|
||||
@@ -529,8 +529,9 @@ exports.newRoot = function newRoot() {
|
||||
if (processConfig.startMode.live !== undefined) {
|
||||
|
||||
if (processConfig.startMode.live.run === "true" && global.EXECUTION_CONFIG.startMode.live.run === "true") {
|
||||
|
||||
|
||||
botConfig.startMode = "Live";
|
||||
console.log(logDisplace + "Root : [INFO] start -> findProcess -> Process found at the bot configuration file. -> Start Mode = " + botConfig.startMode);
|
||||
|
||||
let month = pad((new Date()).getUTCMonth() + 1, 2);
|
||||
let year = (new Date()).getUTCFullYear();
|
||||
@@ -558,6 +559,8 @@ exports.newRoot = function newRoot() {
|
||||
if (processConfig.startMode.backtest.run === "true" && global.EXECUTION_CONFIG.startMode.backtest.run === "true") {
|
||||
|
||||
botConfig.startMode = "Backtest";
|
||||
console.log(logDisplace + "Root : [INFO] start -> findProcess -> Process found at the bot configuration file. -> Start Mode = " + botConfig.startMode);
|
||||
|
||||
botConfig.backtest = processConfig.startMode.backtest;
|
||||
|
||||
/* We override these waitTimes to the one specified at the backtest configuration. */
|
||||
@@ -586,6 +589,8 @@ exports.newRoot = function newRoot() {
|
||||
if (processConfig.startMode.competition.run === "true" && global.EXECUTION_CONFIG.startMode.competition.run === "true") {
|
||||
|
||||
botConfig.startMode = "Competition";
|
||||
console.log(logDisplace + "Root : [INFO] start -> findProcess -> Process found at the bot configuration file. -> Start Mode = " + botConfig.startMode);
|
||||
|
||||
botConfig.competition = processConfig.startMode.competition;
|
||||
|
||||
if (processConfig.startMode.competition.resumeExecution === "false" && global.EXECUTION_CONFIG.startMode.competition.resumeExecution === "false") {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
require('dotenv').config()
|
||||
global.CURRENT_ENVIRONMENT = "Develop";
|
||||
global.CURRENT_EXECUTION_AT = "Cloud";
|
||||
global.SHALL_BOT_STOP = false;
|
||||
@@ -37,30 +37,36 @@ process.on('exit', function (code) {
|
||||
readExecutionConfiguration();
|
||||
|
||||
function readExecutionConfiguration() {
|
||||
let filePath;
|
||||
try {
|
||||
let fs = require('fs');
|
||||
console.log("[INFO] Run -> readExecutionConfiguration -> Entering function. ");
|
||||
|
||||
global.DEV_TEAM = process.env.DEV_TEAM;
|
||||
|
||||
let executionList = [{
|
||||
enabled: "true",
|
||||
devTeam: process.env.DEV_TEAM,
|
||||
bot: process.env.BOT,
|
||||
process: process.env.PROCESS
|
||||
}]
|
||||
|
||||
// TODO Improve this by changing Root.js
|
||||
let mode =
|
||||
'{ "run":"false",' +
|
||||
'"resumeExecution":' + process.env.RESUME_EXECUTION +
|
||||
'}'
|
||||
let startMode = JSON.parse('{ "live": ' + mode +', "backtest": '+mode+', "competition": '+mode+'}')
|
||||
startMode[process.env.START_MODE].run="true"
|
||||
|
||||
let configDirectory = process.argv[2];
|
||||
if (configDirectory === undefined) {
|
||||
console.log("[ERROR] Configuration file not passed as a command line argument.");
|
||||
return;
|
||||
}
|
||||
filePath = configDirectory + '/Execution.Config.json';
|
||||
let executionProperties = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
global.DEV_TEAM = executionProperties.devTeam;
|
||||
global.EXCHANGE_NAME = executionProperties.exchangeName;
|
||||
global.MARKET = executionProperties.market;
|
||||
global.EXECUTION_CONFIG = {
|
||||
executionList: executionProperties.executionList,
|
||||
startMode: executionProperties.startMode
|
||||
executionList: executionList,
|
||||
startMode: startMode
|
||||
};
|
||||
|
||||
readStoragePermissions();
|
||||
}
|
||||
catch (err) {
|
||||
console.log("[ERROR] readExecutionConfiguration -> err = " + err.message);
|
||||
console.log("[HINT] You need to have a file at this path -> " + filePath);
|
||||
console.log("[ERROR] readExecutionConfiguration -> err = " + err.stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
let sasToken = blobService.generateSharedAccessSignature(pContainer, blobName, sharedAccessPolicy);
|
||||
|
||||
return "BlobEndpoint=https://aadevelop.blob.core.windows.net;SharedAccessSignature=" + sasToken + "";
|
||||
|
||||
//return "BlobEndpoint=https://aaproduction.blob.core.windows.net;SharedAccessSignature=" + sasToken + "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@
|
||||
/* We define here all the modules that the rest of the infraestructure, including the bots themselves can consume. */
|
||||
|
||||
const UTILITIES = require(ROOT_DIR + 'CloudUtilities');
|
||||
const EXCHANGE_API = require(ROOT_DIR + 'Exchange/ExchangeAPI');
|
||||
const EXCHANGE_API = require(ROOT_DIR + 'exchange/ExchangeAPI');
|
||||
const CONTEXT = require(ROOT_DIR + 'Context');
|
||||
const ASSISTANT = require(ROOT_DIR + 'Assistant');
|
||||
const STATUS_REPORT = require(ROOT_DIR + 'StatusReport');
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
// TODO integrate with financial beings module to get the exchange
|
||||
let botExchange = 'Poloniex';
|
||||
let exchange = botExchange.toLowerCase() + 'Client.js';
|
||||
let api = require('./Wrappers/' + exchange);
|
||||
let api = require('./wrappers/' + exchange);
|
||||
|
||||
request(authOptions, onTokenResponse);
|
||||
|
||||
@@ -67,7 +67,8 @@
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] createKeyVaultAPIClient -> Entering function."); }
|
||||
|
||||
const keyVaultAPI = graphqlClient({
|
||||
url: 'https://app-api.advancedalgos.net/graphql',
|
||||
//url: 'https://platform-api.advancedalgos.net/graphql',
|
||||
url: 'https://platform-dev-api.advancedalgos.net/graphql',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + authToken
|
||||
}
|
||||
|
||||
Generated
+5
@@ -245,6 +245,11 @@
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "6.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-6.2.0.tgz",
|
||||
"integrity": "sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w=="
|
||||
},
|
||||
"ecc-jsbn": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@
|
||||
"request": "^2.88.0",
|
||||
"retry": "^0.12.0",
|
||||
"underscore": "^1.9.1",
|
||||
"azure-storage": "^2.8.2"
|
||||
"azure-storage": "^2.8.2",
|
||||
"dotenv": "^6.0.0"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user