Cleaning Console Debug stuff

This commit is contained in:
Luis Fernando Molina committed 2018-05-24 12:46:33 +02:00
1 parent b56e0f0125
commit 0baac2f443
5 files changed
+540 -518

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
exports.newBlobStorage = function newBlobStorage(BOT) {
let FULL_LOG = true;
let FULL_LOG = false;
let LOG_FILE_CONTENT = false;
let bot = BOT;
+6 -1
View File
@@ -176,7 +176,7 @@
function write(Message) {
console.log(thisObject.fileName + " " + Message);
console.log("AACloud" + spacePad(thisObject.fileName, 40) + " : " + Message);
if (thisObject.bot === undefined) { return;}
@@ -292,6 +292,11 @@
return str.length < max ? pad("0" + str, max) : str;
}
function spacePad(str, max) {
str = str.toString();
return str.length < max ? spacePad(" " + str, max) : str;
}
function deleteLoopFolder(pFolderPath) {
let fs = require('fs');
+12 -12
View File
@@ -36,7 +36,7 @@
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
poloniexApiClient = new POLONIEX_CLIENT_MODULE(global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Key, global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Secret);
poloniexApiClient = POLONIEX_CLIENT_MODULE.newPoloniexAPIClient(global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Key, global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Secret);
callBackFunction(global.DEFAULT_OK_RESPONSE);
@@ -54,7 +54,7 @@
if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> pMarket = " + JSON.stringify(pMarket)); }
poloniexApiClient.returnOpenOrders(pMarket.assetA, pMarket.assetB, onExchangeCallReturned);
poloniexApiClient.API.returnOpenOrders(pMarket.assetA, pMarket.assetB, onExchangeCallReturned);
function onExchangeCallReturned(err, exchangeResponse) {
@@ -64,7 +64,7 @@
if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> err = " + err); }
if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
poloniexApiClient.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
function onResponseOk() {
@@ -120,7 +120,7 @@
if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> pPositionId = " + pPositionId); }
poloniexApiClient.returnOrderTrades(pPositionId, onExchangeCallReturned);
poloniexApiClient.API.returnOrderTrades(pPositionId, onExchangeCallReturned);
function onExchangeCallReturned(err, exchangeResponse) {
@@ -130,7 +130,7 @@
if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> err = " + err); }
if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
poloniexApiClient.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
function onResponseOk() {
@@ -198,12 +198,12 @@
if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pAmountB = " + pAmountB); }
if (pType === "buy") {
poloniexApiClient.buy(pMarket.assetA, pMarket.assetB, pRate, pAmountB, onExchangeCallReturned);
poloniexApiClient.API.buy(pMarket.assetA, pMarket.assetB, pRate, pAmountB, onExchangeCallReturned);
return;
}
if (pType === "sell") {
poloniexApiClient.sell(pMarket.assetA, pMarket.assetB, pRate, pAmountB, onExchangeCallReturned);
poloniexApiClient.API.sell(pMarket.assetA, pMarket.assetB, pRate, pAmountB, onExchangeCallReturned);
return;
}
@@ -219,7 +219,7 @@
if (FULL_LOG === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> err = " + err); }
if (FULL_LOG === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
poloniexApiClient.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
function onResponseOk() {
@@ -265,7 +265,7 @@
if (FULL_LOG === true) { logger.write("[INFO] movePosition -> pPosition = " + JSON.stringify(pPosition)); }
if (FULL_LOG === true) { logger.write("[INFO] movePosition -> pNewRate = " + pNewRate); }
poloniexApiClient.moveOrder(pPosition.id, pNewRate, pPosition.amountB, onExchangeCallReturned);
poloniexApiClient.API.moveOrder(pPosition.id, pNewRate, pPosition.amountB, onExchangeCallReturned);
function onExchangeCallReturned(err, exchangeResponse) {
@@ -275,7 +275,7 @@
try {
poloniexApiClient.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
function onResponseOk() {
@@ -324,7 +324,7 @@
if (FULL_LOG === true) { logger.write("[INFO] getTicker -> Entering function."); }
poloniexApiClient.returnTicker(onExchangeCallReturned);
poloniexApiClient.API.returnTicker(onExchangeCallReturned);
function onExchangeCallReturned(err, exchangeResponse) {
@@ -334,7 +334,7 @@
try {
poloniexApiClient.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
function onResponseOk() {
+458 -443
View File
@@ -1,465 +1,480 @@
module.exports = (function () {
'use strict';
exports.newPoloniexAPIClient = function newPoloniexAPIClient(pKey, pSecret) {
// Module dependencies
var crypto = require('crypto'),
request = require('request'),
nonce = require('nonce')();
/*
/* ATENTION: This Library is used both a the cloud (AACloud) and also at the AAWeb on the server side without any modifications.
/* There is a second version, stripped of all the inner functionality that runs at AAWeb browser side, which channels the requests to the server side one.
*/
// Constants
var version = '0.0.8',
PUBLIC_API_URL = 'https://poloniex.com/public',
PRIVATE_API_URL = 'https://poloniex.com/tradingApi',
USER_AGENT = 'poloniex.js ' + version;
//USER_AGENT = 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0'
let newFunction = new API(pKey, pSecret);
// Helper methods
function joinCurrencies(currencyA, currencyB) {
// If only one arg, then return the first
if (typeof currencyB !== 'string') {
return currencyA;
let thisObject = {
API: newFunction.prototype
};
return thisObject;
function API () {
'use strict';
// Module dependencies
var crypto = require('crypto'),
request = require('request'),
nonce = require('nonce')();
// Constants
var version = '0.0.8',
PUBLIC_API_URL = 'https://poloniex.com/public',
PRIVATE_API_URL = 'https://poloniex.com/tradingApi',
USER_AGENT = 'poloniex.js ' + version;
//USER_AGENT = 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0'
// Helper methods
function joinCurrencies(currencyA, currencyB) {
// If only one arg, then return the first
if (typeof currencyB !== 'string') {
return currencyA;
}
return currencyA + '_' + currencyB;
}
return currencyA + '_' + currencyB;
}
// Constructor
function Poloniex(key, secret) {
// Generate headers signed by this user's key and secret.
// The secret is encapsulated and never exposed
this._getPrivateHeaders = function (parameters) {
var paramString, signature;
// Constructor
function Poloniex(key, secret) {
// Generate headers signed by this user's key and secret.
// The secret is encapsulated and never exposed
this._getPrivateHeaders = function (parameters) {
var paramString, signature;
if (!key || !secret) {
throw 'Poloniex: Error. API key and secret required';
}
// Convert to `arg1=foo&arg2=bar`
paramString = Object.keys(parameters).map(function (param) {
return encodeURIComponent(param) + '=' + encodeURIComponent(parameters[param]);
}).join('&');
signature = crypto.createHmac('sha512', secret).update(paramString).digest('hex');
return {
Key: key,
Sign: signature
};
};
}
// Currently, this fails with `Error: CERT_UNTRUSTED`
// Poloniex.STRICT_SSL can be set to `false` to avoid this. Use with caution.
// Will be removed in future, once this is resolved.
Poloniex.STRICT_SSL = true;
// Customisable user agent string
Poloniex.USER_AGENT = USER_AGENT;
// Prototype
Poloniex.prototype = {
constructor: Poloniex,
// Make an API request
_request: function (options, callback) {
if (!('headers' in options)) {
options.headers = {};
}
options.json = true;
options.headers['User-Agent'] = Poloniex.USER_AGENT;
options.strictSSL = Poloniex.STRICT_SSL;
request(options, function (err, response, body) {
// Empty response
if (!err && (typeof body === 'undefined' || body === null)) {
err = 'Empty response';
if (!key || !secret) {
throw 'Poloniex: Error. API key and secret required';
}
callback(err, body);
});
// Convert to `arg1=foo&arg2=bar`
paramString = Object.keys(parameters).map(function (param) {
return encodeURIComponent(param) + '=' + encodeURIComponent(parameters[param]);
}).join('&');
return this;
},
signature = crypto.createHmac('sha512', secret).update(paramString).digest('hex');
// Make a public API request
_public: function (command, parameters, callback) {
var options;
if (typeof parameters === 'function') {
callback = parameters;
parameters = {};
}
parameters || (parameters = {});
parameters.command = command;
options = {
method: 'GET',
url: PUBLIC_API_URL,
qs: parameters
return {
Key: key,
Sign: signature
};
};
options.qs.command = command;
return this._request(options, callback);
},
// Make a private API request
_private: function (command, parameters, callback) {
var options;
if (typeof parameters === 'function') {
callback = parameters;
parameters = {};
}
parameters || (parameters = {});
parameters.command = command;
parameters.nonce = nonce();
options = {
method: 'POST',
url: PRIVATE_API_URL,
form: parameters,
headers: this._getPrivateHeaders(parameters)
};
return this._request(options, callback);
},
/////
// PUBLIC METHODS
returnTicker: function (callback) {
return this._public('returnTicker', callback);
},
return24hVolume: function (callback) {
return this._public('return24hVolume', callback);
},
returnOrderBook: function (currencyA, currencyB, depth, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
depth: depth
};
return this._public('returnOrderBook', parameters, callback);
},
returnOrderBooks: function (depth, callback) {
var parameters = {
currencyPair: 'all',
depth: depth
};
return this._public('returnOrderBook', parameters, callback);
},
returnPublicTradeHistory: function (currencyA, currencyB, start, end, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
start: start,
end: end
};
return this._public('returnTradeHistory', parameters, callback);
},
returnChartData: function (currencyA, currencyB, period, start, end, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
period: period,
start: start,
end: end
};
return this._public('returnChartData', parameters, callback);
},
returnCurrencies: function (callback) {
return this._public('returnCurrencies', callback);
},
returnLoanOrders: function (currency, callback) {
return this._public('returnLoanOrders', { currency: currency }, callback);
},
/////
// PRIVATE METHODS
returnBalances: function (callback) {
return this._private('returnBalances', {}, callback);
},
returnCompleteBalances: function (callback) {
return this._private('returnCompleteBalances', {}, callback);
},
returnDepositAddresses: function (callback) {
return this._private('returnDepositAddresses', {}, callback);
},
generateNewAddress: function (currency, callback) {
return this._private('returnDepositsWithdrawals', { currency: currency }, callback);
},
returnDepositsWithdrawals: function (start, end, callback) {
return this._private('returnDepositsWithdrawals', { start: start, end: end }, callback);
},
returnOpenOrders: function (currencyA, currencyB, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
return this._private('returnOpenOrders', parameters, callback);
},
returnTradeHistory: function (currencyA, currencyB, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
return this._private('returnTradeHistory', parameters, callback);
},
returnOrderTrades: function (orderNumber, callback) {
var parameters = {
orderNumber: orderNumber
};
return this._private('returnOrderTrades', parameters, callback);
},
buy: function (currencyA, currencyB, rate, amount, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
rate: rate,
amount: amount
};
return this._private('buy', parameters, callback);
},
sell: function (currencyA, currencyB, rate, amount, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
rate: rate,
amount: amount
};
return this._private('sell', parameters, callback);
},
cancelOrder: function (currencyA, currencyB, orderNumber, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
orderNumber: orderNumber
};
return this._private('cancelOrder', parameters, callback);
},
moveOrder: function (orderNumber, rate, amount, callback) {
var parameters = {
orderNumber: orderNumber,
rate: rate,
amount: amount ? amount : null
};
return this._private('moveOrder', parameters, callback);
},
withdraw: function (currency, amount, address, callback) {
var parameters = {
currency: currency,
amount: amount,
address: address
};
return this._private('withdraw', parameters, callback);
},
returnFeeInfo: function (callback) {
return this._private('returnFeeInfo', {}, callback);
},
returnAvailableAccountBalances: function (account, callback) {
var options = {};
if (account) {
options.account = account;
}
return this._private('returnAvailableAccountBalances', options, callback);
},
returnTradableBalances: function (callback) {
return this._private('returnTradableBalances', {}, callback);
},
transferBalance: function (currency, amount, fromAccount, toAccount, callback) {
var parameters = {
currency: currency,
amount: amount,
fromAccount: fromAccount,
toAccount: toAccount
};
return this._private('transferBalance', parameters, callback);
},
returnMarginAccountSummary: function (callback) {
return this._private('returnMarginAccountSummary', {}, callback);
},
marginBuy: function (currencyA, currencyB, rate, amount, lendingRate, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
rate: rate,
amount: amount,
lendingRate: lendingRate ? lendingRate : null
};
return this._private('marginBuy', parameters, callback);
},
marginSell: function (currencyA, currencyB, rate, amount, lendingRate, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
rate: rate,
amount: amount,
lendingRate: lendingRate ? lendingRate : null
};
return this._private('marginSell', parameters, callback);
},
getMarginPosition: function (currencyA, currencyB, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
return this._private('getMarginPosition', parameters, callback);
},
closeMarginPosition: function (currencyA, currencyB, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
return this._private('closeMarginPosition', parameters, callback);
},
createLoanOffer: function (currency, amount, duration, autoRenew, lendingRate, callback) {
var parameters = {
currency: currency,
amount: amount,
duration: duration,
autoRenew: autoRenew,
lendingRate: lendingRate
};
return this._private('createLoanOffer', parameters, callback);
},
cancelLoanOffer: function (orderNumber, callback) {
var parameters = {
orderNumber: orderNumber
};
return this._private('cancelLoanOffer', parameters, callback);
},
returnOpenLoanOffers: function (callback) {
return this._private('returnOpenLoanOffers', {}, callback);
},
returnActiveLoans: function (callback) {
return this._private('returnActiveLoans', {}, callback);
},
returnLendingHistory: function (start, end, limit, callback) {
var parameters = {
start: start,
end: end,
limit: limit
};
return this._private('returnLendingHistory', parameters, callback);
},
toggleAutoRenew: function (orderNumber, callback) {
return this._private('toggleAutoRenew', { orderNumber: orderNumber }, callback);
},
analizeResponse: function (logger, exchangeErr, exchangeResponse, notOkCallBack, okCallBack) {
/* This function analizes the different situations we might encounter trying to access Poloniex and returns appropiate standard errors. */
try {
let stringExchangeResponse = JSON.stringify(exchangeResponse);
let stringExchangeErr = JSON.stringify(exchangeErr);
logger.write("[INFO] analizeResponse -> exchangeErr = " + stringExchangeErr);
logger.write("[INFO] analizeResponse -> exchangeResponse = " + stringExchangeResponse);
if (stringExchangeErr.indexOf("ETIMEDOUT") > 0 ||
stringExchangeErr.indexOf("ENOTFOUND") > 0 ||
stringExchangeErr.indexOf("ECONNREFUSED") > 0 ||
stringExchangeErr.indexOf("ESOCKETTIMEDOUT") > 0 ||
stringExchangeErr.indexOf("ECONNRESET") > 0 ||
(stringExchangeResponse !== undefined && (
stringExchangeResponse.indexOf("Connection timed out") > 0 ||
stringExchangeResponse.indexOf("Connection Error") > 0 ||
stringExchangeResponse.indexOf("Bad gateway") > 0 ||
stringExchangeResponse.indexOf("Internal error. Please try again") > 0))) {
logger.write("[WARN] analizeResponse -> Timeout reached or connection problem while trying to access the Exchange API. Requesting new execution later.");
notOkCallBack(global.DEFAULT_RETRY_RESPONSE);
return;
} else {
if (JSON.stringify(exchangeResponse).indexOf("error") > 0) {
logger.write("[ERROR] analizeResponse -> Unexpected response from the Exchange.");
notOkCallBack(global.DEFAULT_FAIL_RESPONSE);
return;
}
if (exchangeErr) {
logger.write("[ERROR] analizeResponse -> Unexpected error trying to contact the Exchange.");
notOkCallBack(global.DEFAULT_FAIL_RESPONSE);
}
// Currently, this fails with `Error: CERT_UNTRUSTED`
// Poloniex.STRICT_SSL can be set to `false` to avoid this. Use with caution.
// Will be removed in future, once this is resolved.
Poloniex.STRICT_SSL = true;
// Customisable user agent string
Poloniex.USER_AGENT = USER_AGENT;
// Prototype
Poloniex.prototype = {
constructor: Poloniex,
// Make an API request
_request: function (options, callback) {
if (!('headers' in options)) {
options.headers = {};
}
options.json = true;
options.headers['User-Agent'] = Poloniex.USER_AGENT;
options.strictSSL = Poloniex.STRICT_SSL;
request(options, function (err, response, body) {
// Empty response
if (!err && (typeof body === 'undefined' || body === null)) {
err = 'Empty response';
}
callback(err, body);
});
return this;
},
// Make a public API request
_public: function (command, parameters, callback) {
var options;
if (typeof parameters === 'function') {
callback = parameters;
parameters = {};
}
parameters || (parameters = {});
parameters.command = command;
options = {
method: 'GET',
url: PUBLIC_API_URL,
qs: parameters
};
options.qs.command = command;
return this._request(options, callback);
},
// Make a private API request
_private: function (command, parameters, callback) {
var options;
if (typeof parameters === 'function') {
callback = parameters;
parameters = {};
}
parameters || (parameters = {});
parameters.command = command;
parameters.nonce = nonce();
options = {
method: 'POST',
url: PRIVATE_API_URL,
form: parameters,
headers: this._getPrivateHeaders(parameters)
};
return this._request(options, callback);
},
/////
// PUBLIC METHODS
returnTicker: function (callback) {
return this._public('returnTicker', callback);
},
return24hVolume: function (callback) {
return this._public('return24hVolume', callback);
},
returnOrderBook: function (currencyA, currencyB, depth, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
depth: depth
};
return this._public('returnOrderBook', parameters, callback);
},
returnOrderBooks: function (depth, callback) {
var parameters = {
currencyPair: 'all',
depth: depth
};
return this._public('returnOrderBook', parameters, callback);
},
returnPublicTradeHistory: function (currencyA, currencyB, start, end, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
start: start,
end: end
};
return this._public('returnTradeHistory', parameters, callback);
},
returnChartData: function (currencyA, currencyB, period, start, end, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
period: period,
start: start,
end: end
};
return this._public('returnChartData', parameters, callback);
},
returnCurrencies: function (callback) {
return this._public('returnCurrencies', callback);
},
returnLoanOrders: function (currency, callback) {
return this._public('returnLoanOrders', { currency: currency }, callback);
},
/////
// PRIVATE METHODS
returnBalances: function (callback) {
return this._private('returnBalances', {}, callback);
},
returnCompleteBalances: function (callback) {
return this._private('returnCompleteBalances', {}, callback);
},
returnDepositAddresses: function (callback) {
return this._private('returnDepositAddresses', {}, callback);
},
generateNewAddress: function (currency, callback) {
return this._private('returnDepositsWithdrawals', { currency: currency }, callback);
},
returnDepositsWithdrawals: function (start, end, callback) {
return this._private('returnDepositsWithdrawals', { start: start, end: end }, callback);
},
returnOpenOrders: function (currencyA, currencyB, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
return this._private('returnOpenOrders', parameters, callback);
},
returnTradeHistory: function (currencyA, currencyB, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
return this._private('returnTradeHistory', parameters, callback);
},
returnOrderTrades: function (orderNumber, callback) {
var parameters = {
orderNumber: orderNumber
};
return this._private('returnOrderTrades', parameters, callback);
},
buy: function (currencyA, currencyB, rate, amount, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
rate: rate,
amount: amount
};
return this._private('buy', parameters, callback);
},
sell: function (currencyA, currencyB, rate, amount, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
rate: rate,
amount: amount
};
return this._private('sell', parameters, callback);
},
cancelOrder: function (currencyA, currencyB, orderNumber, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
orderNumber: orderNumber
};
return this._private('cancelOrder', parameters, callback);
},
moveOrder: function (orderNumber, rate, amount, callback) {
var parameters = {
orderNumber: orderNumber,
rate: rate,
amount: amount ? amount : null
};
return this._private('moveOrder', parameters, callback);
},
withdraw: function (currency, amount, address, callback) {
var parameters = {
currency: currency,
amount: amount,
address: address
};
return this._private('withdraw', parameters, callback);
},
returnFeeInfo: function (callback) {
return this._private('returnFeeInfo', {}, callback);
},
returnAvailableAccountBalances: function (account, callback) {
var options = {};
if (account) {
options.account = account;
}
return this._private('returnAvailableAccountBalances', options, callback);
},
returnTradableBalances: function (callback) {
return this._private('returnTradableBalances', {}, callback);
},
transferBalance: function (currency, amount, fromAccount, toAccount, callback) {
var parameters = {
currency: currency,
amount: amount,
fromAccount: fromAccount,
toAccount: toAccount
};
return this._private('transferBalance', parameters, callback);
},
returnMarginAccountSummary: function (callback) {
return this._private('returnMarginAccountSummary', {}, callback);
},
marginBuy: function (currencyA, currencyB, rate, amount, lendingRate, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
rate: rate,
amount: amount,
lendingRate: lendingRate ? lendingRate : null
};
return this._private('marginBuy', parameters, callback);
},
marginSell: function (currencyA, currencyB, rate, amount, lendingRate, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB),
rate: rate,
amount: amount,
lendingRate: lendingRate ? lendingRate : null
};
return this._private('marginSell', parameters, callback);
},
getMarginPosition: function (currencyA, currencyB, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
return this._private('getMarginPosition', parameters, callback);
},
closeMarginPosition: function (currencyA, currencyB, callback) {
var parameters = {
currencyPair: joinCurrencies(currencyA, currencyB)
};
return this._private('closeMarginPosition', parameters, callback);
},
createLoanOffer: function (currency, amount, duration, autoRenew, lendingRate, callback) {
var parameters = {
currency: currency,
amount: amount,
duration: duration,
autoRenew: autoRenew,
lendingRate: lendingRate
};
return this._private('createLoanOffer', parameters, callback);
},
cancelLoanOffer: function (orderNumber, callback) {
var parameters = {
orderNumber: orderNumber
};
return this._private('cancelLoanOffer', parameters, callback);
},
returnOpenLoanOffers: function (callback) {
return this._private('returnOpenLoanOffers', {}, callback);
},
returnActiveLoans: function (callback) {
return this._private('returnActiveLoans', {}, callback);
},
returnLendingHistory: function (start, end, limit, callback) {
var parameters = {
start: start,
end: end,
limit: limit
};
return this._private('returnLendingHistory', parameters, callback);
},
toggleAutoRenew: function (orderNumber, callback) {
return this._private('toggleAutoRenew', { orderNumber: orderNumber }, callback);
},
analizeResponse: function (logger, exchangeErr, exchangeResponse, notOkCallBack, okCallBack) {
/* This function analizes the different situations we might encounter trying to access Poloniex and returns appropiate standard errors. */
try {
let stringExchangeResponse = JSON.stringify(exchangeResponse);
let stringExchangeErr = JSON.stringify(exchangeErr);
logger.write("[INFO] analizeResponse -> exchangeErr = " + stringExchangeErr);
logger.write("[INFO] analizeResponse -> exchangeResponse = " + stringExchangeResponse);
if (stringExchangeErr.indexOf("ETIMEDOUT") > 0 ||
stringExchangeErr.indexOf("ENOTFOUND") > 0 ||
stringExchangeErr.indexOf("ECONNREFUSED") > 0 ||
stringExchangeErr.indexOf("ESOCKETTIMEDOUT") > 0 ||
stringExchangeErr.indexOf("ECONNRESET") > 0 ||
(stringExchangeResponse !== undefined && (
stringExchangeResponse.indexOf("Connection timed out") > 0 ||
stringExchangeResponse.indexOf("Connection Error") > 0 ||
stringExchangeResponse.indexOf("Bad gateway") > 0 ||
stringExchangeResponse.indexOf("Internal error. Please try again") > 0))) {
logger.write("[WARN] analizeResponse -> Timeout reached or connection problem while trying to access the Exchange API. Requesting new execution later.");
notOkCallBack(global.DEFAULT_RETRY_RESPONSE);
return;
} else {
logger.write("[INFO] analizeResponse -> No problem found.");
okCallBack();
return;
if (JSON.stringify(exchangeResponse).indexOf("error") > 0) {
logger.write("[ERROR] analizeResponse -> Unexpected response from the Exchange.");
notOkCallBack(global.DEFAULT_FAIL_RESPONSE);
return;
}
if (exchangeErr) {
logger.write("[ERROR] analizeResponse -> Unexpected error trying to contact the Exchange.");
notOkCallBack(global.DEFAULT_FAIL_RESPONSE);
return;
} else {
logger.write("[INFO] analizeResponse -> No problem found.");
okCallBack();
return;
}
}
} catch (err) {
logger.write("[ERROR] analizeResponse -> err.message = " + err.message);
notOkCallBack(global.DEFAULT_FAIL_RESPONSE);
return;
}
} catch (err) {
logger.write("[ERROR] analizeResponse -> err.message = " + err.message);
notOkCallBack(global.DEFAULT_FAIL_RESPONSE);
return;
}
}
};
};
// Backwards Compatibility
Poloniex.prototype.getTicker = Poloniex.prototype.returnTicker;
Poloniex.prototype.get24hVolume = Poloniex.prototype.return24hVolume;
Poloniex.prototype.getOrderBook = Poloniex.prototype.returnOrderBook;
Poloniex.prototype.getTradeHistory = Poloniex.prototype.returnChartData;
Poloniex.prototype.myBalances = Poloniex.prototype.returnBalances;
Poloniex.prototype.myOpenOrders = Poloniex.prototype.returnOpenOrders;
Poloniex.prototype.myTradeHistory = Poloniex.prototype.returnTradeHistory;
return Poloniex;
})();
// Backwards Compatibility
Poloniex.prototype.getTicker = Poloniex.prototype.returnTicker;
Poloniex.prototype.get24hVolume = Poloniex.prototype.return24hVolume;
Poloniex.prototype.getOrderBook = Poloniex.prototype.returnOrderBook;
Poloniex.prototype.getTradeHistory = Poloniex.prototype.returnChartData;
Poloniex.prototype.myBalances = Poloniex.prototype.returnBalances;
Poloniex.prototype.myOpenOrders = Poloniex.prototype.returnOpenOrders;
Poloniex.prototype.myTradeHistory = Poloniex.prototype.returnTradeHistory;
return Poloniex;
}
}
+63 -61
View File
@@ -89,12 +89,14 @@ exports.newRoot = function newRoot() {
let cloudStorage;
let logDisplace = "AACloud" + " ";
return thisObject;
function initialize(callBackFunction) {
try {
console.log("[INFO] Root -> initialize -> Entering function. ");
console.log(logDisplace + "Root : [INFO] initialize -> Entering function. ");
const BLOB_STORAGE = require(ROOT_DIR + 'BlobStorage');
cloudStorage = BLOB_STORAGE.newBlobStorage();
@@ -113,7 +115,7 @@ exports.newRoot = function newRoot() {
function onFileReceived(err, text) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
console.log("[ERROR] Root -> initialize -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [INFO] initialize -> onInizialized -> onFileReceived -> err = " + err.message);
return;
}
@@ -121,19 +123,19 @@ exports.newRoot = function newRoot() {
global.PLATFORM_CONFIG = JSON.parse(text);
callBackFunction();
} catch (err) {
console.log("[ERROR] Root -> initialize -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] initialize -> onInizialized -> onFileReceived -> err = " + err.message);
return;
}
}
} else {
console.log("[ERROR] Root -> initialize -> onInizialized -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] initialize -> onInizialized -> err = " + err.message);
return;
}
}
}
catch (err) {
console.log("[ERROR] Root -> initialize -> err.message = " + err.message);
console.log(logDisplace + "Root : [ERROR] initialize -> err.message = " + err.message);
return;
}
}
@@ -167,8 +169,8 @@ exports.newRoot = function newRoot() {
if (listItem.enabled !== "true") {
console.log("[INFO] Root -> start -> Skipping process for being disabled.");
console.log("[INFO] Root -> start -> listItem.process = " + listItem.process);
console.log(logDisplace + "Root : [INFO] start -> Skipping process for being disabled.");
console.log(logDisplace + "Root : [INFO] start -> listItem.process = " + listItem.process);
continue;
}
@@ -182,7 +184,7 @@ exports.newRoot = function newRoot() {
function getBotConfig() {
try {
console.log("[INFO] Root -> start -> getBotConfig -> Entering function. ");
console.log(logDisplace + "Root : [INFO] start -> getBotConfig -> Entering function. ");
const BLOB_STORAGE = require(ROOT_DIR + 'BlobStorage');
let cloudStorage = BLOB_STORAGE.newBlobStorage(listItem);
@@ -201,7 +203,7 @@ exports.newRoot = function newRoot() {
function onFileReceived(err, text) {
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
console.log("[ERROR] Root -> start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
return;
}
@@ -210,19 +212,19 @@ exports.newRoot = function newRoot() {
botConfig.repo = listItem.repo;
findProcess();
} catch (err) {
console.log("[ERROR] Root -> start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> onFileReceived -> err = " + err.message);
return;
}
}
} else {
console.log("[ERROR] Root -> start -> getBotConfig -> onInizialized -> err = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> onInizialized -> err = " + err.message);
return;
}
}
}
catch (err) {
console.log("[ERROR] Root -> start -> getBotConfig -> err.message = " + err.message);
console.log(logDisplace + "Root : [ERROR] start -> getBotConfig -> err.message = " + err.message);
return;
}
}
@@ -230,7 +232,7 @@ exports.newRoot = function newRoot() {
function findProcess() {
try {
if (FULL_LOG === true) { console.log("[INFO] Root -> start -> findProcess -> Entering function. "); }
if (FULL_LOG === true) { console.log(logDisplace + "Root : [INFO] start -> findProcess -> Entering function. "); }
botConfig.process = listItem.process;
botConfig.debug = {};
@@ -243,14 +245,14 @@ exports.newRoot = function newRoot() {
botConfig.loopCounter = 0;
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> Processing item from executionList -> p = " + p); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> listItem.botPath = " + listItem.botPath); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> Processing item from executionList -> p = " + p); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> listItem.botPath = " + listItem.botPath); }
/* File Path Root */
botConfig.filePathRoot = botConfig.devTeam + "/" + botConfig.codeName + "." + botConfig.version.major + "." + botConfig.version.minor + "/" + global.PLATFORM_CONFIG.codeName + "." + global.PLATFORM_CONFIG.version.major + "." + global.PLATFORM_CONFIG.version.minor + "/" + global.EXCHANGE_NAME + "/" + botConfig.dataSetVersion;
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> listItem.process = " + listItem.process); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> listItem.process = " + listItem.process); }
/* Now we loop throug all the configured processes at each bots configuration until we find the one we are supposed to run at this Node.js process. */
@@ -261,7 +263,7 @@ exports.newRoot = function newRoot() {
if (botConfig.processes[i].name === listItem.process) {
processFound = true;
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> Process found at the bot configuration file. -> listItem.process = " + listItem.process); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> Process found at the bot configuration file. -> listItem.process = " + listItem.process); }
let processConfig = botConfig.processes[i];
@@ -273,7 +275,7 @@ exports.newRoot = function newRoot() {
if (processConfig.startMode.allMonths.run === "true") {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> allMonths start mode detected. "); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> allMonths start mode detected. "); }
for (let year = processConfig.startMode.allMonths.maxYear; year >= processConfig.startMode.allMonths.minYear; year--) {
@@ -293,7 +295,7 @@ exports.newRoot = function newRoot() {
function startProcess() {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> startProcess -> Ready to start process."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> startProcess -> Ready to start process."); }
switch (botConfig.type) {
case 'Extraction': {
@@ -305,7 +307,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> startProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> startProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -318,13 +320,13 @@ exports.newRoot = function newRoot() {
if (processConfig.startMode.oneMonth.run === "true") {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> oneMonth start mode detected. "); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> oneMonth start mode detected. "); }
startProcess();
function startProcess() {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> startProcess -> Ready to start process."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> startProcess -> Ready to start process."); }
let month = pad(processConfig.startMode.oneMonth.month, 2);
let year = processConfig.startMode.oneMonth.year;
@@ -344,7 +346,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> startProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> startProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -374,7 +376,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -396,7 +398,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -423,7 +425,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -451,7 +453,7 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
@@ -476,29 +478,29 @@ exports.newRoot = function newRoot() {
break;
}
default: {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
logger.write("[ERROR] start -> findProcess -> Unexpected bot type. -> botConfig.type = " + botConfig.type);
}
}
}
}
} catch (err) {
logger.write("[ERROR] Root -> start -> findProcess -> Unexpected exception. -> err.message = " + err.message);
logger.write("[ERROR] start -> findProcess -> Unexpected exception. -> err.message = " + err.message);
}
}
}
if (processFound === false) {
logger.write("[ERROR] Root -> Process listed at the configuration file of AACloud not found at the configuration file of the bot. -> listItem.process = " + listItem.process);
logger.write("[ERROR] Process listed at the configuration file of AACloud not found at the configuration file of the bot. -> listItem.process = " + listItem.process);
}
function runExtractionBot(pBotConfig, pProcessConfig, pMonth, pYear) {
try {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess ->runExtractionBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess ->runExtractionBot -> pMonth = " + pMonth); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess ->runExtractionBot -> pYear = " + pYear); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess ->runExtractionBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess ->runExtractionBot -> pMonth = " + pMonth); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess ->runExtractionBot -> pYear = " + pYear); }
let extractionBotMainLoop = EXTRACTION_BOT_MAIN_LOOP_MODULE.newExtractionBotProcessMainLoop(pBotConfig);
extractionBotMainLoop.initialize(pProcessConfig, onInitializeReady);
@@ -520,16 +522,16 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished sucessfully. :-)");
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] Root -> start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] start -> findProcess -> runExtractionBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished with errors. Please check the logs. :-(");
}
}
@@ -548,9 +550,9 @@ exports.newRoot = function newRoot() {
function runIndicatorBot(pBotConfig, pProcessConfig, pMonth, pYear) {
try {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> pMonth = " + pMonth); }
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> pYear = " + pYear); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> runIndicatorBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> runIndicatorBot -> pMonth = " + pMonth); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> runIndicatorBot -> pYear = " + pYear); }
let indicatorBotMainLoop = INDICATOR_BOT_MAIN_LOOP_MODULE.newIndicatorBotProcessMainLoop(pBotConfig);
indicatorBotMainLoop.initialize(pProcessConfig, onInitializeReady);
@@ -572,23 +574,23 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[INFO] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished sucessfully. :-)");
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished with errors. Please check the logs. :-(");
}
}
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runIndicatorBot -> onInitializeReady -> Bot will not be started. ");
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runIndicatorBot -> onInitializeReady -> Bot will not be started. ");
}
}
}
@@ -600,7 +602,7 @@ exports.newRoot = function newRoot() {
function runTradingBot(pBotConfig, pProcessConfig) {
try {
if (FULL_LOG === true) { logger.write("[INFO] Root -> start -> findProcess -> runTradingBot -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] start -> findProcess -> runTradingBot -> Entering function."); }
let tradingBotMainLoop = TRADING_BOT_MAIN_LOOP_MODULE.newTradingBotProcessMainLoop(pBotConfig);
tradingBotMainLoop.initialize(pProcessConfig, onInitializeReady);
@@ -619,34 +621,34 @@ exports.newRoot = function newRoot() {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
logger.write("[INFO] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[INFO] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot execution finished sucessfully. :-)");
logger.write("[INFO] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished sucessfully. :-)");
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Execution will be stopped. ");
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bye. :-(");
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> whenStartFinishes -> Bot Id = " + botId);
console.log(botId + " Bot execution finished with errors. Please check the logs. :-(");
}
}
} else {
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> err = " + err.message);
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> onInitializeReady -> Bot will not be started. ");
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runTradingBot -> onInitializeReady -> Bot will not be started. ");
}
}
}
catch (err) {
logger.write("[ERROR] Root -> start -> findProcess -> runTradingBot -> err = " + err.message);
logger.write("[ERROR] start -> findProcess -> runTradingBot -> err = " + err.message);
}
}
}
catch (err) {
logger.write("[ERROR] Root -> start -> findProcess -> err.message = " + err.message);
logger.write("[ERROR] start -> findProcess -> err.message = " + err.message);
return;
}
}