Some refactoring

This commit is contained in:
Luis Fernando Molina committed 2018-03-06 17:00:59 +01:00
1 parent b882f7c096
commit 450aba0b09
5 files changed
+61 -61

No files matched your search

Binary file not shown.
+22 -22
View File
@@ -84,7 +84,7 @@
} catch (err) {
logger.write("[ERROR] initialize -> err = " + err);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
@@ -109,13 +109,13 @@
readStatusAndContext();
}
break;
case 'Retry Later.': { // Something bad happened, but if we retry in a while it might go through the next time.
case 'Retry Later': { // Something bad happened, but if we retry in a while it might go through the next time.
logger.write("[ERROR] getPositionsAtExchange -> onResponse -> Retry Later. Requesting Execution Retry.");
callBackFunction(true, nextIntervalLapse);
return;
}
break;
case 'Operation Failed.': { // This is an unexpected exception that we do not know how to handle.
case 'Operation Failed': { // This is an unexpected exception that we do not know how to handle.
logger.write("[ERROR] getPositionsAtExchange -> onResponse -> Operation Failed. Aborting the process.");
return;
}
@@ -124,7 +124,7 @@
}
} catch (err) {
logger.write("[ERROR] getPositionsAtExchange -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -231,7 +231,7 @@
botContext.executionContext.positions[i].amountB !== sumAssetB
) {
logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> Cannot be confirmed that a partially execution was done well.");
callBack("Operation Failed.");
callBack("Operation Failed");
return;
}
@@ -266,7 +266,7 @@
} catch (err) {
logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
return;
}
}
@@ -308,7 +308,7 @@
botContext.executionContext.positions[i].amountB !== sumAssetB
) {
logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> Cannot be confirmed that the order was executed. It must be manually cancelled by the user or cancelled by the exchange itself.");
callBack("Operation Failed.");
callBack("Operation Failed");
return;
}
@@ -341,14 +341,14 @@
} catch (err) {
logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
return;
}
}
} catch (err) {
logger.write("[ERROR] ordersExecutionCheck -> loopBody -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
return;
}
}
@@ -380,7 +380,7 @@
}
} catch (err) {
logger.write("[ERROR] ordersExecutionCheck -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -403,13 +403,13 @@
callBack(pTrades);
}
break;
case 'Retry Later.': { // Something bad happened, but if we retry in a while it might go through the next time.
case 'Retry Later': { // Something bad happened, but if we retry in a while it might go through the next time.
logger.write("[ERROR] getPositionTradesAtExchange -> onResponse -> Retry Later. Requesting Execution Retry.");
callBackFunction(true, nextIntervalLapse);
return;
}
break;
case 'Operation Failed.': { // This is an unexpected exception that we do not know how to handle.
case 'Operation Failed': { // This is an unexpected exception that we do not know how to handle.
logger.write("[ERROR] getPositionTradesAtExchange -> onResponse -> Operation Failed. Aborting the process.");
return;
}
@@ -417,12 +417,12 @@
}
} catch (err) {
logger.write("[ERROR] getPositionTradesAtExchange -> onResponse -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] getPositionTradesAtExchange -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -463,13 +463,13 @@
callBack();
}
break;
case 'Retry Later.': { // Something bad happened, but if we retry in a while it might go through the next time.
case 'Retry Later': { // Something bad happened, but if we retry in a while it might go through the next time.
logger.write("[ERROR] putPositionAtExchange -> onResponse -> Retry Later. Requesting Execution Retry.");
callBackFunction(true, nextIntervalLapse);
return;
}
break;
case 'Operation Failed.': { // This is an unexpected exception that we do not know how to handle.
case 'Operation Failed': { // This is an unexpected exception that we do not know how to handle.
logger.write("[ERROR] putPositionAtExchange -> onResponse -> Operation Failed. Aborting the process.");
return;
}
@@ -477,12 +477,12 @@
}
} catch (err) {
logger.write("[ERROR] putPositionAtExchange -> onResponse -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] putPositionAtExchange -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -536,13 +536,13 @@
callBack();
}
break;
case 'Retry Later.': { // Something bad happened, but if we retry in a while it might go through the next time.
case 'Retry Later': { // Something bad happened, but if we retry in a while it might go through the next time.
logger.write("[ERROR] movePositionAtExchange -> onResponse -> Retry Later. Requesting Execution Retry.");
callBackFunction(true, nextIntervalLapse);
return;
}
break;
case 'Operation Failed.': { // This is an unexpected exception that we do not know how to handle.
case 'Operation Failed': { // This is an unexpected exception that we do not know how to handle.
logger.write("[ERROR] movePositionAtExchange -> onResponse -> Operation Failed. Aborting the process.");
return;
}
@@ -550,12 +550,12 @@
}
} catch (err) {
logger.write("[ERROR] movePositionAtExchange -> onResponse -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] movePositionAtExchange -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
};
+2 -2
View File
@@ -223,7 +223,7 @@
} catch (err) {
logger.write("[ERROR] initialize -> err = " + err);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
@@ -378,7 +378,7 @@
} catch (err) {
logger.write("[ERROR] saveAll -> Error = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
+10 -10
View File
@@ -42,7 +42,7 @@
} catch (err) {
logger.write("[ERROR] initialize -> err = " + err);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
@@ -84,7 +84,7 @@
}
} catch (err) {
logger.write("[ERROR] getCandles -> getMarketFiles -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -111,7 +111,7 @@
}
} catch (err) {
logger.write("[ERROR] getCandles -> getDailyFiles -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -174,13 +174,13 @@
}
} catch (err) {
logger.write("[ERROR] getCandles -> getCandlesWeAreIn -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] getCandles -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -221,7 +221,7 @@
}
} catch (err) {
logger.write("[ERROR] getPatterns -> getMarketFiles -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -248,7 +248,7 @@
}
} catch (err) {
logger.write("[ERROR] getPatterns -> getDailyFiles -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -313,13 +313,13 @@
}
} catch (err) {
logger.write("[ERROR] getPatterns -> getStairsWeAreIn -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] getPatterns -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
@@ -361,7 +361,7 @@
} catch (err) {
logger.write("[ERROR] getPatterns -> err = " + err);
callBack("Operation Failed.");
callBack("Operation Failed");
}
}
};
+27 -27
View File
@@ -47,14 +47,14 @@
logger.write("[HINT] The file must have the keys to access your poloniex account, in this format -> " + '{ "Key" : "4FB9TMEB-234VH2W1-BYJIXHGM-GL15DSA1", "Secret" : "1a24298skdjdf734uuyhbdagdasdtyut276587256hdsdas765asdasdasd76asdasda765asdasfas6asfda57657asd5a76sd5a7s65d7a6sd57as65d7as65d"}');
logger.write("[HINT] You get this key logging in to your Poloniex web account, enabling API keys and getting a new one. ");
logger.write("[HINT] Be sure not to allow withdrawls with this Key. When asked at the exchange key page, say no. ");
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] initialize -> err = " + err);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
@@ -74,7 +74,7 @@
if (err.message.indexOf("ETIMEDOUT") > 0) {
logger.write("[WARN] getOpenPositions -> onExchangeCallReturned -> Timeout reached while trying to access the Exchange API. Requesting new execution later. : ERROR = " + err.message);
callBackFunction("Retry Later.");
callBackFunction("Retry Later");
return;
} else {
@@ -82,19 +82,19 @@
if (err.message.indexOf("ECONNRESET") > 0) {
logger.write("[WARN] getOpenPositions -> onExchangeCallReturned -> The exchange reseted the connection. Requesting new execution later. : ERROR = " + err.message);
callBackFunction("Retry Later.");
callBackFunction("Retry Later");
return;
} else {
logger.write("[ERROR] getOpenPositions -> onExchangeCallReturned -> Unexpected error trying to contact the Exchange. This will halt this bot process. : ERROR = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
return;
}
}
} catch (err) {
logger.write("[ERROR] getOpenPositions -> onExchangeCallReturned -> exchangeResponse.error = " + exchangeResponse.error);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
return;
}
@@ -138,12 +138,12 @@
}
catch (err) {
logger.write("[ERROR] getOpenPositions -> onExchangeCallReturned -> Error = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] getOpenPositions -> onExchangeCallReturned -> Error = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
@@ -163,7 +163,7 @@
if (err.message.indexOf("ETIMEDOUT") > 0) {
logger.write("[WARN] getExecutedTrades -> onExchangeCallReturned -> Timeout reached while trying to access the Exchange API. Requesting new execution later. : ERROR = " + err.message);
callBackFunction("Retry Later.");
callBackFunction("Retry Later");
return;
} else {
@@ -171,19 +171,19 @@
if (err.message.indexOf("ECONNRESET") > 0) {
logger.write("[WARN] getExecutedTrades -> onExchangeCallReturned -> The exchange reseted the connection. Requesting new execution later. : ERROR = " + err.message);
callBackFunction("Retry Later.");
callBackFunction("Retry Later");
return;
} else {
logger.write("[ERROR] getExecutedTrades -> onExchangeCallReturned -> Unexpected error trying to contact the Exchange. This will halt this bot process. : ERROR = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
return;
}
}
} catch (err) {
logger.write("[ERROR] getExecutedTrades -> onExchangeCallReturned -> exchangeResponse.error = " + exchangeResponse.error);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
return;
}
@@ -234,12 +234,12 @@
}
catch (err) {
logger.write("[ERROR] getExecutedTrades -> onExchangeCallReturned -> Error = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] getExecutedTrades -> onExchangeCallReturned -> Error = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
@@ -263,7 +263,7 @@
if (err.message.indexOf("ETIMEDOUT") > 0) {
logger.write("[WARN] putPosition -> onExchangeCallReturned -> Timeout reached while trying to access the Exchange API. Requesting new execution later. : ERROR = " + err.message);
callBackFunction("Retry Later.");
callBackFunction("Retry Later");
return;
} else {
@@ -271,19 +271,19 @@
if (err.message.indexOf("ECONNRESET") > 0) {
logger.write("[WARN] putPosition -> onExchangeCallReturned -> The exchange reseted the connection. Requesting new execution later. : ERROR = " + err.message);
callBackFunction("Retry Later.");
callBackFunction("Retry Later");
return;
} else {
logger.write("[ERROR] putPosition -> onExchangeCallReturned -> Unexpected error trying to contact the Exchange. This will halt this bot process. : ERROR = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
return;
}
}
} catch (err) {
logger.write("[ERROR] putPosition -> onExchangeCallReturned -> exchangeResponse.error = " + exchangeResponse.error);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
return;
}
@@ -315,13 +315,13 @@
}
catch (err) {
logger.write("[ERROR] putPosition -> onExchangeCallReturned -> Error = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] putPosition -> err = " + err);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
@@ -341,7 +341,7 @@
if (err.message.indexOf("ETIMEDOUT") > 0) {
logger.write("[WARN] movePosition -> onExchangeCallReturned -> Timeout reached while trying to access the Exchange API. Requesting new execution later. : ERROR = " + err.message);
callBackFunction("Retry Later.");
callBackFunction("Retry Later");
return;
} else {
@@ -349,19 +349,19 @@
if (err.message.indexOf("ECONNRESET") > 0) {
logger.write("[WARN] movePosition -> onExchangeCallReturned -> The exchange reseted the connection. Requesting new execution later. : ERROR = " + err.message);
callBackFunction("Retry Later.");
callBackFunction("Retry Later");
return;
} else {
logger.write("[ERROR] movePosition -> onExchangeCallReturned -> Unexpected error trying to contact the Exchange. This will halt this bot process. : ERROR = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
return;
}
}
} catch (err) {
logger.write("[ERROR] movePosition -> onExchangeCallReturned -> exchangeResponse.error = " + exchangeResponse.error);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
return;
}
@@ -371,7 +371,7 @@
if (exchangeResponse.success !== 1) {
logger.write("[ERROR] movePosition -> onExchangeCallReturned -> exchangeResponse.success = " + exchangeResponse.success);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
return;
}
/*
@@ -398,13 +398,13 @@
}
catch (err) {
logger.write("[ERROR] movePosition -> onExchangeCallReturned -> Error = " + err.message);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
} catch (err) {
logger.write("[ERROR] movePosition -> err = " + err);
callBackFunction("Operation Failed.");
callBackFunction("Operation Failed");
}
}
};