Breakpoint at code!

This commit is contained in:
Luis Fernando Molina committed 2018-06-02 00:06:36 +02:00
1 parent 9b3ba12dc7
commit b6bd28c4e6
2 files changed
+39 -32

No files matched your search

+38 -32
View File
@@ -4,7 +4,7 @@
let bot = BOT;
const MODULE_NAME = "User Bot";
const MODULE_NAME = 'User Bot';
const LOG_INFO = true;
const logger = DEBUG_MODULE.newDebugLog();
@@ -25,19 +25,19 @@
try {
if (LOG_INFO === true) { logger.write("[INFO] initialize -> Entering function."); }
if (LOG_INFO === true) { logger.write('[INFO] initialize -> Entering function.'); }
logger.fileName = MODULE_NAME;
/* Store local values. */
assistant = pAssistant;
logger.write("[INFO] initialize -> Entering function 'initialize' ");
logger.write('[INFO] initialize -> Entering function initialize ');
callBackFunction(global.DEFAULT_OK_RESPONSE);
} catch (err) {
logger.write("[ERROR] initialize -> onDone -> err = " + err.message);
logger.write('[ERROR] initialize -> onDone -> err = ' + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -46,7 +46,7 @@
try {
if (LOG_INFO === true) { logger.write("[INFO] start -> Entering function."); }
if (LOG_INFO === true) { logger.write('[INFO] start -> Entering function.'); }
/*
@@ -56,6 +56,12 @@
*/
if (AT_BREAKPOINT === true) {
if (FULL_LOG === true) { logger.write("[INFO] run -> loop -> Plot Breakpoint Hit."); }
}
decideWhatToDo(onDone);
function onDone(err) {
@@ -63,19 +69,19 @@
switch (err.result) {
case global.DEFAULT_OK_RESPONSE.result: {
logger.write("[INFO] start -> onDone -> Execution finished well. :-)");
logger.write('[INFO] start -> onDone -> Execution finished well. :-)');
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
}
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] start -> onDone -> Retry Later. Requesting Execution Retry.");
logger.write('[ERROR] start -> onDone -> Retry Later. Requesting Execution Retry.');
callBackFunction(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] start -> onDone -> Operation Failed. Aborting the process.");
logger.write('[ERROR] start -> onDone -> Operation Failed. Aborting the process.');
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
@@ -83,7 +89,7 @@
}
} catch (err) {
logger.write("[ERROR] start -> onDone -> err = " + err.message);
logger.write('[ERROR] start -> onDone -> err = ' + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -92,7 +98,7 @@
try {
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> Entering function."); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> Entering function.'); }
let balance = assistant.getAvailableBalance();
@@ -107,7 +113,7 @@
if (balanceA === 0 && balanceB === 0) {
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> Cannot place orders since Available Balance is zero on both Assets."); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> Cannot place orders since Available Balance is zero on both Assets.'); }
callBack(global.DEFAULT_OK_RESPONSE);
return;
@@ -116,15 +122,15 @@
switch (messageRelevance) {
case 1: {
assistant.sendMessage(messageRelevance, "No Available Balance","Cannot place orders since Available Balance is zero on both Assets.");
assistant.sendMessage(messageRelevance, 'No Available Balance','Cannot place orders since Available Balance is zero on both Assets.');
break;
}
case 3: {
assistant.sendMessage(messageRelevance, "Available Balance Too Low", "Available balances too low on both assets.");
assistant.sendMessage(messageRelevance, 'Available Balance Too Low', 'Available balances too low on both assets.');
break;
}
case 5: {
assistant.sendMessage(messageRelevance, "Orders Already at Order Book", "All intended orders have already been put at the order book.");
assistant.sendMessage(messageRelevance, 'Orders Already at Order Book', 'All intended orders have already been put at the order book.');
break;
}
@@ -138,21 +144,21 @@
switch (messageRelevance) {
case 1: {
assistant.sendMessage(messageRelevance, "Feeling Lazy", "I don't feel like putting any order by now. Will think about it later.");
assistant.sendMessage(messageRelevance, 'Feeling Lazy', 'I dont feel like putting any order by now. Will think about it later.');
break;
}
case 3: {
assistant.sendMessage(messageRelevance, "Not Right Time", "According to my internal calculations, this is not a good time to place an order.");
assistant.sendMessage(messageRelevance, 'Not Right Time', 'According to my internal calculations, this is not a good time to place an order.');
break;
}
case 5: {
assistant.sendMessage(messageRelevance, "Not Feeling Lucky", "I am currently not feeling lucky, for that reason I wont put any order now.");
assistant.sendMessage(messageRelevance, 'Not Feeling Lucky', 'I am currently not feeling lucky, for that reason I wont put any order now.');
break;
}
}
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> In some situations it is just fin no to place orders. Passing this turn. "); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> In some situations it is just fin no to place orders. Passing this turn. '); }
callBack(global.DEFAULT_OK_RESPONSE);
return;
}
@@ -165,14 +171,14 @@
amountB = amountA / rate;
amountB = Number(amountB.toFixed(8));
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> Decided to BUY."); }
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> amountA = " + amountA); }
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> amountB = " + amountB); }
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> rate = " + rate); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> Decided to BUY.'); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> amountA = ' + amountA); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> amountB = ' + amountB); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> rate = ' + rate); }
assistant.putPosition("buy", rate, amountA, amountB, callBack);
assistant.putPosition('buy', rate, amountA, amountB, callBack);
assistant.sendMessage(10, "Buy Order Placed", "I ve just placed a Buy order because I thought the rate " + rate + " was great.");
assistant.sendMessage(10, 'Buy Order Placed', 'I ve just placed a Buy order because I thought the rate ' + rate + ' was great.');
}
if (balanceB > 0) {
@@ -183,24 +189,24 @@
amountA = amountB * rate;
amountA = Number(amountA.toFixed(8));
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> Decided to SELL."); }
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> amountA = " + amountA); }
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> amountB = " + amountB); }
if (LOG_INFO === true) { logger.write("[INFO] start -> decideWhatToDo -> rate = " + rate); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> Decided to SELL.'); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> amountA = ' + amountA); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> amountB = ' + amountB); }
if (LOG_INFO === true) { logger.write('[INFO] start -> decideWhatToDo -> rate = ' + rate); }
assistant.putPosition("sell", rate, amountA, amountB, callBack);
assistant.putPosition('sell', rate, amountA, amountB, callBack);
assistant.sendMessage(10, "Sell Order Placed", "I ve just placed a Sell order because I believe it was the right time to do so.");
assistant.sendMessage(10, 'Sell Order Placed', 'I ve just placed a Sell order because I believe it was the right time to do so.');
}
} catch (err) {
logger.write("[ERROR] start -> decideWhatToDo -> err = " + err.message);
logger.write('[ERROR] start -> decideWhatToDo -> err = ' + err.message);
callBack(global.DEFAULT_FAIL_RESPONSE);
}
}
} catch (err) {
logger.write("[ERROR] start -> err = " + err.message);
logger.write('[ERROR] start -> err = ' + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
+1
View File
@@ -36,6 +36,7 @@
"retryWaitTime": 10000,
"sleepWaitTime": 3600000,
"comaWaitTime": 86400000,
"timePeriod": 60000,
"statusDependencies": [
{
"devTeam": "AAMasters",