diff --git a/.vs/AACloudPlatform/v15/.suo b/.vs/AACloudPlatform/v15/.suo
index a22487ba6..32d71c950 100644
Binary files a/.vs/AACloudPlatform/v15/.suo and b/.vs/AACloudPlatform/v15/.suo differ
diff --git a/AACloudPlatform.sln b/AACloudPlatform.sln
index 3de48b31a..a21837e88 100644
--- a/AACloudPlatform.sln
+++ b/AACloudPlatform.sln
@@ -1,9 +1,9 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.26730.10
+VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "AACloudPlatform", "AACloudPlatform.njsproj", "{AE0A3FE2-7021-4CC2-9922-A887CA5CDD7C}"
+Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "Project", "Project.njsproj", "{AE0A3FE2-7021-4CC2-9922-A887CA5CDD7C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
diff --git a/ExchangeAPI.js b/ExchangeAPI.js
index d123c3f6d..9163b3fe8 100644
--- a/ExchangeAPI.js
+++ b/ExchangeAPI.js
@@ -80,35 +80,9 @@
if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> err = " + err); }
if (FULL_LOG === true) { logger.write("[INFO] getOpenPositions -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
- if (err || exchangeResponse.error !== undefined || exchangeResponse.indexOf("Connection timed out") > 0) {
- try {
+ if (err || exchangeResponse.error !== undefined || JSON.stringify(exchangeResponse).indexOf("Connection timed out") > 0) {
- if (err.message.indexOf("ETIMEDOUT") > 0 || exchangeResponse.indexOf("Connection timed out") > 0) {
-
- logger.write("[WARN] getOpenPositions -> onExchangeCallReturned -> Timeout reached while trying to access the Exchange API. Requesting new execution later. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_RETRY_RESPONSE);
- return;
-
- } else {
-
- if (err.message.indexOf("ECONNRESET") > 0) {
-
- logger.write("[WARN] getOpenPositions -> onExchangeCallReturned -> The exchange reseted the connection. Requesting new execution later. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_RETRY_RESPONSE);
- return;
-
- } else {
- logger.write("[ERROR] getOpenPositions -> onExchangeCallReturned -> Unexpected error trying to contact the Exchange. This will halt this bot process. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_FAIL_RESPONSE);
- return;
- }
- }
-
- } catch (err) {
- logger.write("[ERROR] getOpenPositions -> onExchangeCallReturned -> exchangeResponse.error = " + exchangeResponse.error);
- callBackFunction(global.DEFAULT_FAIL_RESPONSE);
- return;
- }
+ somethingWentWrong(err, exchangeResponse, callBackFunction);
} else {
@@ -174,35 +148,10 @@
if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> err = " + err); }
if (FULL_LOG === true) { logger.write("[INFO] getExecutedTrades -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
- if (err || exchangeResponse.error !== undefined || exchangeResponse.indexOf("Connection timed out") > 0) {
- try {
+ if (err || exchangeResponse.error !== undefined || JSON.stringify(exchangeResponse).indexOf("Connection timed out") > 0) {
- if (err.message.indexOf("ETIMEDOUT") > 0 || exchangeResponse.indexOf("Connection timed out") > 0) {
+ somethingWentWrong(err, exchangeResponse, callBackFunction);
- logger.write("[WARN] getExecutedTrades -> onExchangeCallReturned -> Timeout reached while trying to access the Exchange API. Requesting new execution later. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_RETRY_RESPONSE);
- return;
-
- } else {
-
- if (err.message.indexOf("ECONNRESET") > 0) {
-
- logger.write("[WARN] getExecutedTrades -> onExchangeCallReturned -> The exchange reseted the connection. Requesting new execution later. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_RETRY_RESPONSE);
- return;
-
- } else {
- logger.write("[ERROR] getExecutedTrades -> onExchangeCallReturned -> Unexpected error trying to contact the Exchange. This will halt this bot process. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_FAIL_RESPONSE);
- return;
- }
- }
-
- } catch (err) {
- logger.write("[ERROR] getExecutedTrades -> onExchangeCallReturned -> exchangeResponse.error = " + exchangeResponse.error);
- callBackFunction(global.DEFAULT_FAIL_RESPONSE);
- return;
- }
} else {
/*
@@ -290,35 +239,9 @@
if (FULL_LOG === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> err = " + err); }
if (FULL_LOG === true) { logger.write("[INFO] putPosition -> onExchangeCallReturned -> exchangeResponse = " + JSON.stringify(exchangeResponse)); }
- if (err || exchangeResponse.error !== undefined || exchangeResponse.indexOf("Connection timed out") > 0) {
- try {
+ if (err || exchangeResponse.error !== undefined || JSON.stringify(exchangeResponse).indexOf("Connection timed out") > 0) {
- if (err.message.indexOf("ETIMEDOUT") > 0 || exchangeResponse.indexOf("Connection timed out") > 0) {
-
- logger.write("[WARN] putPosition -> onExchangeCallReturned -> Timeout reached while trying to access the Exchange API. Requesting new execution later. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_RETRY_RESPONSE);
- return;
-
- } else {
-
- if (err.message.indexOf("ECONNRESET") > 0) {
-
- logger.write("[WARN] putPosition -> onExchangeCallReturned -> The exchange reseted the connection. Requesting new execution later. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_RETRY_RESPONSE);
- return;
-
- } else {
- logger.write("[ERROR] putPosition -> onExchangeCallReturned -> Unexpected error trying to contact the Exchange. This will halt this bot process. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_FAIL_RESPONSE);
- return;
- }
- }
-
- } catch (err) {
- logger.write("[ERROR] putPosition -> onExchangeCallReturned -> exchangeResponse.error = " + exchangeResponse.error);
- callBackFunction(global.DEFAULT_FAIL_RESPONSE);
- return;
- }
+ somethingWentWrong(err, exchangeResponse, callBackFunction);
} else {
@@ -374,35 +297,9 @@
try {
- if (err || exchangeResponse.error !== undefined || exchangeResponse.indexOf("Connection timed out") > 0) {
- try {
+ if (err || exchangeResponse.error !== undefined || JSON.stringify(exchangeResponse).indexOf("Connection timed out") > 0) {
- if (err.message.indexOf("ETIMEDOUT") > 0 || exchangeResponse.indexOf("Connection timed out") > 0) {
-
- logger.write("[WARN] movePosition -> onExchangeCallReturned -> Timeout reached while trying to access the Exchange API. Requesting new execution later. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_RETRY_RESPONSE);
- return;
-
- } else {
-
- if (err.message.indexOf("ECONNRESET") > 0) {
-
- logger.write("[WARN] movePosition -> onExchangeCallReturned -> The exchange reseted the connection. Requesting new execution later. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_RETRY_RESPONSE);
- return;
-
- } else {
- logger.write("[ERROR] movePosition -> onExchangeCallReturned -> Unexpected error trying to contact the Exchange. This will halt this bot process. : ERROR = " + err.message);
- callBackFunction(global.DEFAULT_FAIL_RESPONSE);
- return;
- }
- }
-
- } catch (err) {
- logger.write("[ERROR] movePosition -> onExchangeCallReturned -> exchangeResponse.error = " + exchangeResponse.error);
- callBackFunction(global.DEFAULT_FAIL_RESPONSE);
- return;
- }
+ somethingWentWrong(err, exchangeResponse, callBackFunction);
} else {
@@ -444,4 +341,39 @@
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
+
+ function somethingWentWrong(err, exchangeResponse, callBackFunction) {
+
+ try {
+
+ logger.write("[WARN] somethingWentWrong -> err = " + JSON.stringify(err));
+ logger.write("[WARN] somethingWentWrong -> exchangeResponse = " + JSON.stringify(exchangeResponse));
+
+ if (JSON.stringify(err).indexOf("ETIMEDOUT") > 0 || JSON.stringify(exchangeResponse).indexOf("Connection timed out") > 0) {
+
+ logger.write("[WARN] somethingWentWrong -> Timeout reached while trying to access the Exchange API. Requesting new execution later.");
+ callBackFunction(global.DEFAULT_RETRY_RESPONSE);
+ return;
+
+ } else {
+
+ if (JSON.stringify(err).indexOf("ECONNRESET") > 0) {
+
+ logger.write("[WARN] somethingWentWrong -> The exchange reseted the connection. Requesting new execution later.");
+ callBackFunction(global.DEFAULT_RETRY_RESPONSE);
+ return;
+
+ } else {
+ logger.write("[ERROR] somethingWentWrong -> Unexpected error trying to contact the Exchange. This will halt this bot process.");
+ callBackFunction(global.DEFAULT_FAIL_RESPONSE);
+ return;
+ }
+ }
+
+ } catch (err) {
+ logger.write("[ERROR] somethingWentWrong -> err.message = " + err.message);
+ callBackFunction(global.DEFAULT_FAIL_RESPONSE);
+ return;
+ }
+ }
};
\ No newline at end of file
diff --git a/AACloudPlatform.njsproj b/Project.njsproj
similarity index 99%
rename from AACloudPlatform.njsproj
rename to Project.njsproj
index df7231810..1eb413ca3 100644
--- a/AACloudPlatform.njsproj
+++ b/Project.njsproj
@@ -12,7 +12,7 @@
{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}
14.0
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- AACloudPlatform
+ Project
Trading-Process
C:\Program Files\nodejs\node.exe
False
diff --git a/obj/Debug/Project.njsproj.FileListAbsolute.txt b/obj/Debug/Project.njsproj.FileListAbsolute.txt
new file mode 100644
index 000000000..71fd7f7bc
--- /dev/null
+++ b/obj/Debug/Project.njsproj.FileListAbsolute.txt
@@ -0,0 +1,2 @@
+C:\Users\Luis\source\repos\AACloudPlatform\obj\Debug\Project.njsproj.CoreCompileInputs.cache
+C:\Users\Luis\source\repos\AACloudPlatform\bin\Microsoft.NodejsTools.WebRole.dll