diff --git a/.vs/AACloudPlatform/v15/.suo b/.vs/AACloudPlatform/v15/.suo index 07cda9ff6..40fd77d6e 100644 Binary files a/.vs/AACloudPlatform/v15/.suo and b/.vs/AACloudPlatform/v15/.suo differ diff --git a/Assistant.js b/Assistant.js index 03275c99d..2b247af77 100644 --- a/Assistant.js +++ b/Assistant.js @@ -281,9 +281,61 @@ getPositionTradesAtExchange(botContext.executionContext.positions[i].id, confirmOrderWasExecuted); + function getPositionTradesAtExchange(pPositionId, innerCallBack) { + + try { + + if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> pPositionId = " + pPositionId); } + + /* + + Given one position, we request all the associated trades to it. + + */ + + exchangeAPI.getExecutedTrades(pPositionId, onResponse); + + function onResponse(err, pTrades) { + + try { + switch (err.result) { + case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested. + logger.write("[INFO] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Execution finished well. :-)"); + innerCallBack(pTrades); + } + break; + case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Retry Later. Requesting Execution Retry."); + callBack(global.DEFAULT_RETRY_RESPONSE); + return; + } + break; + case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Operation Failed. Aborting the process."); + callBack(global.DEFAULT_FAIL_RESPONSE); + return; + } + break; + } + } catch (err) { + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> err = " + err.message); + callBack(global.DEFAULT_FAIL_RESPONSE); + } + } + } catch (err) { + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> err = " + err.message); + callBack(global.DEFAULT_FAIL_RESPONSE); + } + } + function confirmOrderWasExecuted(pTrades) { try { + + if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> Entering function."); } + if (FULL_LOG === true) { logger.write("[INFO] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> pTrades = " + JSON.stringify(pTrades)); } + /* To confirm everything is ok, we will add all the amounts on trades asociated to the order and @@ -349,49 +401,6 @@ } } - function getPositionTradesAtExchange(pPositionId, innerCallBack) { - - try { - /* - - Given one position, we request all the associated trades to it. - - */ - - exchangeAPI.getExecutedTrades(pPositionId, onResponse); - - function onResponse(err, pTrades) { - - try { - switch (err.result) { - case global.DEFAULT_OK_RESPONSE.result: { // Everything went well, we have the information requested. - innerCallBack(pTrades); - } - break; - case global.DEFAULT_RETRY_RESPONSE.result: { // Something bad happened, but if we retry in a while it might go through the next time. - logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Retry Later. Requesting Execution Retry."); - callBack(global.DEFAULT_RETRY_RESPONSE); - return; - } - break; - case global.DEFAULT_FAIL_RESPONSE.result: { // This is an unexpected exception that we do not know how to handle. - logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> Operation Failed. Aborting the process."); - callBack(global.DEFAULT_FAIL_RESPONSE); - return; - } - break; - } - } catch (err) { - logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> onResponse -> err = " + err.message); - callBack(global.DEFAULT_FAIL_RESPONSE); - } - } - } catch (err) { - logger.write("[ERROR] ordersExecutionCheck -> loopBody -> getPositionTradesAtExchange -> err = " + err.message); - callBack(global.DEFAULT_FAIL_RESPONSE); - } - } - } catch (err) { logger.write("[ERROR] ordersExecutionCheck -> loopBody -> err = " + err.message); callBack(global.DEFAULT_FAIL_RESPONSE); diff --git a/Context.js b/Context.js index 258c63e12..cbad33bed 100644 --- a/Context.js +++ b/Context.js @@ -397,6 +397,8 @@ try { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeExecutionContext -> onFolderCreated -> err = " + err.message); callBack(err); @@ -409,6 +411,8 @@ function onFileCreated(err) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExecutionContext -> onFolderCreated -> onFileCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeExecutionContext -> onFolderCreated -> onFileCreated -> err = " + err.message); callBack(err); @@ -453,6 +457,8 @@ try { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeExucutionHistory -> onFolderCreated -> err = " + err.message); callBack(err); @@ -475,6 +481,8 @@ function onFileCreated(err) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeExucutionHistory -> onFolderCreated -> onFileCreated -> err = " + err.message); callBack(err); @@ -519,6 +527,8 @@ try { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeStatusReport -> onFolderCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeStatusReport -> onFolderCreated -> err = " + err.message); callBack(err); @@ -533,6 +543,8 @@ function onFileCreated(err) { + if (FULL_LOG === true) { logger.write("[INFO] saveThemAll -> writeStatusReport -> onFolderCreated -> onFileCreated -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] saveThemAll -> writeStatusReport -> onFolderCreated -> onFileCreated -> err = " + err.message); callBack(err); diff --git a/ExchangeAPI.js b/ExchangeAPI.js index 2a5f3a3c3..e4e589732 100644 --- a/ExchangeAPI.js +++ b/ExchangeAPI.js @@ -361,8 +361,8 @@ try { if (FULL_LOG === true) { logger.write("[INFO] movePosition -> Entering function."); } - if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pPosition = " + JSON.stringify(pPosition)); } - if (FULL_LOG === true) { logger.write("[INFO] putPosition -> pNewRate = " + pNewRate); } + 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); diff --git a/Utilities.js b/Utilities.js index 1f98a896b..b2a0384c4 100644 --- a/Utilities.js +++ b/Utilities.js @@ -27,6 +27,8 @@ exports.newUtilities = function newUtilities(BOT) { function createFolderIfNeeded(path, azureFileStorage, callBackFunction) { + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> Entering function."); } + let splittedPath = path.split("/"); let partialPath = ''; @@ -37,6 +39,8 @@ exports.newUtilities = function newUtilities(BOT) { function loop() { + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> loop -> Entering function."); } + partialPath = partialPath + separator + splittedPath[i]; separator = "/"; @@ -46,6 +50,8 @@ exports.newUtilities = function newUtilities(BOT) { function checkLoop(err) { + if (FULL_LOG === true) { logger.write("[INFO] createFolderIfNeeded -> loop -> checkLoop -> Entering function."); } + if (err.result !== global.DEFAULT_OK_RESPONSE.result) { logger.write("[ERROR] createFolderIfNeeded -> loop -> checkLoop -> err = " + err.message); callBackFunction(err);