Fully debugged

This commit is contained in:
Luis Fernando Molina committed 2018-03-08 20:20:59 +01:00
1 parent b8c69bb74c
commit 3abcb1bc2b
8 files changed
+79 -73

No files matched your search

Binary file not shown.
+2 -2
View File
@@ -10,7 +10,7 @@
const MODULE_NAME = "Assistant";
thisObject = {
let thisObject = {
initialize: initialize,
putPositionAtExchange: putPositionAtExchange,
movePositionAtExchange: movePositionAtExchange
@@ -30,7 +30,7 @@
return thisObject;
function initialize(pProcessDatetime, pBotContext, pExchangeAPI, callBackFunction) {
function initialize(pBotContext, pExchangeAPI, callBackFunction) {
try {
+14 -12
View File
@@ -31,7 +31,7 @@
*/
thisObject = {
let thisObject = {
statusReport: undefined, // Here is the information that defines which was the last sucessfull execution and some other details.
executionHistory: [], // This is the record of bot execution.
executionContext: undefined, // Here is the business information of the last execution of this bot process.
@@ -140,7 +140,7 @@
if (FULL_LOG === true) { logger.write("[INFO] initialize -> getStatusReport -> Entering function."); }
let fileName = "Status.Report.json"
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.version + "/" + bot.dataSetVersion + "/Processes/" + bot.process + "/" + global.EXCHANGE_NAME;
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.dataSetVersion + "/Processes/" + bot.process + "/" + global.EXCHANGE_NAME;
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
@@ -194,7 +194,7 @@
if (FULL_LOG === true) { logger.write("[INFO] initialize -> getExecutionHistory -> Entering function."); }
let fileName = "Execution.History.json"
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.version + "/" + bot.dataSetVersion + "/Output/" + bot.process + "/" + global.EXCHANGE_NAME;
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.dataSetVersion + "/Output/" + bot.process + "/" + global.EXCHANGE_NAME;
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
@@ -245,7 +245,7 @@
let fileName = "Execution.Context.json"
let dateForPath = date.getUTCFullYear() + '/' + utilities.pad(date.getUTCMonth() + 1, 2) + '/' + utilities.pad(date.getUTCDate(), 2) + '/' + utilities.pad(date.getUTCHours(), 2) + '/' + utilities.pad(date.getUTCMinutes(), 2);
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.version + "/" + bot.dataSetVersion + "/Output/" + bot.process + "/" + global.EXCHANGE_NAME + "/" + dateForPath;
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.dataSetVersion + "/Output/" + bot.process + "/" + global.EXCHANGE_NAME + "/" + dateForPath;
cloudStorage.getTextFile(filePath, fileName, onFileReceived);
@@ -299,6 +299,8 @@
*/
thisObject.statusReport = {};
thisObject.executionHistory = [];
thisObject.executionContext = {
@@ -374,7 +376,7 @@
let fileName = "Execution.Context.json"
let dateForPath = global.processDatetime.getUTCFullYear() + '/' + utilities.pad(global.processDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(global.processDatetime.getUTCDate(), 2) + '/' + utilities.pad(global.processDatetime.getUTCHours(), 2) + '/' + utilities.pad(global.processDatetime.getUTCMinutes(), 2);
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.version + "/" + bot.dataSetVersion + "/Output/" + bot.process + "/" + global.EXCHANGE_NAME + "/" + dateForPath;
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.dataSetVersion + "/Output/" + bot.process + "/" + global.EXCHANGE_NAME + "/" + dateForPath;
utilities.createFolderIfNeeded(filePath, cloudStorage, onFolderCreated);
@@ -429,7 +431,7 @@
try {
let fileName = "Execution.History.json"
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.version + "/" + bot.dataSetVersion + "/Output/" + bot.process + "/" + global.EXCHANGE_NAME;
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.dataSetVersion + "/Output/" + bot.process + "/" + global.EXCHANGE_NAME;
utilities.createFolderIfNeeded(filePath, cloudStorage, onFolderCreated);
@@ -444,11 +446,11 @@
}
let newRecord = [
newHistoryRecord.date.valueOf(),
newHistoryRecord.rate,
newHistoryRecord.newPositions,
newHistoryRecord.newTrades,
newHistoryRecord.movedPositions
thisObject.newHistoryRecord.date.valueOf(),
thisObject.newHistoryRecord.rate,
thisObject.newHistoryRecord.newPositions,
thisObject.newHistoryRecord.newTrades,
thisObject.newHistoryRecord.movedPositions
];
thisObject.executionHistory.push(newRecord);
@@ -494,7 +496,7 @@
try {
let fileName = "Status.Report.json"
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.version + "/" + bot.dataSetVersion + "/Processes/" + bot.process + "/" + global.EXCHANGE_NAME;
let filePath = bot.devTeam + "/" + bot.codeName + "/" + bot.dataSetVersion + "/Processes/" + bot.process + "/" + global.EXCHANGE_NAME;
utilities.createFolderIfNeeded(filePath, cloudStorage, onFolderCreated);
+21 -50
View File
@@ -10,7 +10,7 @@
const MODULE_NAME = "Datasource";
thisObject = {
let thisObject = {
initialize: initialize,
candlesFiles: new Map, // Complete sets of candles for different Time Periods. For Time Periods < 1hs sets are of current day only, otherwise whole market.
candlesMap: new Map, // The last 10 candles for each Time Period will be stored here.
@@ -24,35 +24,6 @@
logger.fileName = MODULE_NAME;
logger.bot = bot;
let marketFilesPeriods =
'[' +
'[' + 24 * 60 * 60 * 1000 + ',' + '"24-hs"' + ']' + ',' +
'[' + 12 * 60 * 60 * 1000 + ',' + '"12-hs"' + ']' + ',' +
'[' + 8 * 60 * 60 * 1000 + ',' + '"08-hs"' + ']' + ',' +
'[' + 6 * 60 * 60 * 1000 + ',' + '"06-hs"' + ']' + ',' +
'[' + 4 * 60 * 60 * 1000 + ',' + '"04-hs"' + ']' + ',' +
'[' + 3 * 60 * 60 * 1000 + ',' + '"03-hs"' + ']' + ',' +
'[' + 2 * 60 * 60 * 1000 + ',' + '"02-hs"' + ']' + ',' +
'[' + 1 * 60 * 60 * 1000 + ',' + '"01-hs"' + ']' + ']';
marketFilesPeriods = JSON.parse(marketFilesPeriods);
let dailyFilePeriods =
'[' +
'[' + 45 * 60 * 1000 + ',' + '"45-min"' + ']' + ',' +
'[' + 40 * 60 * 1000 + ',' + '"40-min"' + ']' + ',' +
'[' + 30 * 60 * 1000 + ',' + '"30-min"' + ']' + ',' +
'[' + 20 * 60 * 1000 + ',' + '"20-min"' + ']' + ',' +
'[' + 15 * 60 * 1000 + ',' + '"15-min"' + ']' + ',' +
'[' + 10 * 60 * 1000 + ',' + '"10-min"' + ']' + ',' +
'[' + 05 * 60 * 1000 + ',' + '"05-min"' + ']' + ',' +
'[' + 04 * 60 * 1000 + ',' + '"04-min"' + ']' + ',' +
'[' + 03 * 60 * 1000 + ',' + '"03-min"' + ']' + ',' +
'[' + 02 * 60 * 1000 + ',' + '"02-min"' + ']' + ',' +
'[' + 01 * 60 * 1000 + ',' + '"01-min"' + ']' + ']';
dailyFilePeriods = JSON.parse(dailyFilePeriods);
let oliviaAzureFileStorage = FILE_STORAGE.newAzureFileStorage(bot);
let tomAzureFileStorage = FILE_STORAGE.newAzureFileStorage(bot);
@@ -148,10 +119,10 @@
let filesOk = 0;
let filesNotOk = 0;
for (i = 0; i < marketFilesPeriods.length; i++) {
for (i = 0; i < global.marketFilesPeriods.length; i++) {
let periodTime = marketFilesPeriods[i][0];
let periodName = marketFilesPeriods[i][1];
let periodTime = global.marketFilesPeriods[i][0];
let periodName = global.marketFilesPeriods[i][1];
getFile(oliviaAzureFileStorage, "@AssetA_@AssetB.json", "@Exchange/Output/Candles/Multi-Period-Market/@Period", periodName, undefined, onFileReceived, callBack);
@@ -164,9 +135,9 @@
filesNotOk++;
}
if (filesOk + filesNotOk === marketFilesPeriods.length) {
if (filesOk + filesNotOk === global.marketFilesPeriods.length) {
if (filesOk === marketFilesPeriods.length) {
if (filesOk === global.marketFilesPeriods.length) {
getDailyFiles();
@@ -192,10 +163,10 @@
let filesOk = 0;
let filesNotOk = 0;
for (i = 0; i < dailyFilePeriods.length; i++) {
for (i = 0; i < global.dailyFilePeriods.length; i++) {
let periodTime = dailyFilePeriods[i][0];
let periodName = dailyFilePeriods[i][1];
let periodTime = global.dailyFilePeriods[i][0];
let periodName = global.dailyFilePeriods[i][1];
getFile(oliviaAzureFileStorage, "@AssetA_@AssetB.json", "@Exchange/Output/Candles/Multi-Period-Daily/@Period/@Year/@Month/@Day", periodName, global.processDatetime, onFileReceived, callBack);
@@ -208,9 +179,9 @@
filesNotOk++;
}
if (filesOk + filesNotOk === dailyFilePeriods.length) {
if (filesOk + filesNotOk === global.dailyFilePeriods.length) {
if (filesOk === dailyFilePeriods.length) {
if (filesOk === global.dailyFilePeriods.length) {
getCandlesWeAreIn();
@@ -317,10 +288,10 @@
let filesOk = 0;
let filesNotOk = 0;
for (i = 0; i < marketFilesPeriods.length; i++) {
for (i = 0; i < global.marketFilesPeriods.length; i++) {
let periodTime = marketFilesPeriods[i][0];
let periodName = marketFilesPeriods[i][1];
let periodTime = global.marketFilesPeriods[i][0];
let periodName = global.marketFilesPeriods[i][1];
getFile(tomAzureFileStorage, "@AssetA_@AssetB.json", "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Market/@Period", periodName, undefined, onFileReceived, callBack);
@@ -333,9 +304,9 @@
filesNotOk++;
}
if (filesOk + filesNotOk === marketFilesPeriods.length) {
if (filesOk + filesNotOk === global.marketFilesPeriods.length) {
if (filesOk === marketFilesPeriods.length) {
if (filesOk === global.marketFilesPeriods.length) {
getDailyFiles();
@@ -361,10 +332,10 @@
let filesOk = 0;
let filesNotOk = 0;
for (i = 0; i < dailyFilePeriods.length; i++) {
for (i = 0; i < global.dailyFilePeriods.length; i++) {
let periodTime = dailyFilePeriods[i][0];
let periodName = dailyFilePeriods[i][1];
let periodTime = global.dailyFilePeriods[i][0];
let periodName = global.dailyFilePeriods[i][1];
getFile(tomAzureFileStorage, "@AssetA_@AssetB.json", "@Exchange/Tom/dataSet.V1/Output/Candle-Stairs/Multi-Period-Daily/@Period/@Year/@Month/@Day", periodName, global.processDatetime, onFileReceived, callBack);
@@ -377,9 +348,9 @@
filesNotOk++;
}
if (filesOk + filesNotOk === dailyFilePeriods.length) {
if (filesOk + filesNotOk === global.dailyFilePeriods.length) {
if (filesOk === dailyFilePeriods.length) {
if (filesOk === global.dailyFilePeriods.length) {
getStairsWeAreIn();
+6 -6
View File
@@ -10,7 +10,7 @@
const MODULE_NAME = "Exchange API";
thisObject = {
let thisObject = {
initialize: initialize,
getOpenPositions: getOpenPositions,
getExecutedTrades: getExecutedTrades,
@@ -136,7 +136,7 @@
exchangePositions.push(openPosition);
}
callBackFunction(null, exchangePositions);
callBackFunction(global.DEFAULT_OK_RESPONSE, exchangePositions);
}
}
catch (err) {
@@ -229,7 +229,7 @@
trades.push(trade);
}
callBackFunction(null, trades);
callBackFunction(global.DEFAULT_OK_RESPONSE, trades);
}
}
catch (err) {
@@ -316,7 +316,7 @@
*/
callBackFunction(null, exchangeResponse.orderNumber);
callBackFunction(global.DEFAULT_OK_RESPONSE, exchangeResponse.orderNumber);
}
}
catch (err) {
@@ -331,7 +331,7 @@
}
}
function movePosition(pPosition, pNewRate) {
function movePosition(pPosition, pNewRate, callBackFunction) {
try {
@@ -397,7 +397,7 @@
*/
callBackFunction(null, exchangeResponse.orderNumber);
callBackFunction(global.DEFAULT_OK_RESPONSE, exchangeResponse.orderNumber);
}
}
catch (err) {
+33
View File
@@ -92,8 +92,41 @@ global.MARKET = {
assetB: "BTC",
};
/* Currently only one exchange is supported. */
global.EXCHANGE_NAME = "Poloniex";
/* Time Periods Definitions. */
global.marketFilesPeriods =
'[' +
'[' + 24 * 60 * 60 * 1000 + ',' + '"24-hs"' + ']' + ',' +
'[' + 12 * 60 * 60 * 1000 + ',' + '"12-hs"' + ']' + ',' +
'[' + 8 * 60 * 60 * 1000 + ',' + '"08-hs"' + ']' + ',' +
'[' + 6 * 60 * 60 * 1000 + ',' + '"06-hs"' + ']' + ',' +
'[' + 4 * 60 * 60 * 1000 + ',' + '"04-hs"' + ']' + ',' +
'[' + 3 * 60 * 60 * 1000 + ',' + '"03-hs"' + ']' + ',' +
'[' + 2 * 60 * 60 * 1000 + ',' + '"02-hs"' + ']' + ',' +
'[' + 1 * 60 * 60 * 1000 + ',' + '"01-hs"' + ']' + ']';
global.marketFilesPeriods = JSON.parse(global.marketFilesPeriods);
global.dailyFilePeriods =
'[' +
'[' + 45 * 60 * 1000 + ',' + '"45-min"' + ']' + ',' +
'[' + 40 * 60 * 1000 + ',' + '"40-min"' + ']' + ',' +
'[' + 30 * 60 * 1000 + ',' + '"30-min"' + ']' + ',' +
'[' + 20 * 60 * 1000 + ',' + '"20-min"' + ']' + ',' +
'[' + 15 * 60 * 1000 + ',' + '"15-min"' + ']' + ',' +
'[' + 10 * 60 * 1000 + ',' + '"10-min"' + ']' + ',' +
'[' + 05 * 60 * 1000 + ',' + '"05-min"' + ']' + ',' +
'[' + 04 * 60 * 1000 + ',' + '"04-min"' + ']' + ',' +
'[' + 03 * 60 * 1000 + ',' + '"03-min"' + ']' + ',' +
'[' + 02 * 60 * 1000 + ',' + '"02-min"' + ']' + ',' +
'[' + 01 * 60 * 1000 + ',' + '"01-min"' + ']' + ']';
global.dailyFilePeriods = JSON.parse(global.dailyFilePeriods);
const START_ALL_MONTHS = false;
+2 -2
View File
@@ -13,7 +13,7 @@
logger.fileName = MODULE_NAME;
logger.bot = bot;
thisObject = {
let thisObject = {
initialize: initialize,
run: run
};
@@ -254,7 +254,7 @@
if (FULL_LOG === true) { logger.write("[INFO] run -> loop -> startUserBot -> Entering function."); }
usertBot.run(platform, onFinished);
usertBot.start(onFinished);
function onFinished(err) {
+1 -1
View File
@@ -54,7 +54,7 @@ exports.newUtilities = function newUtilities(BOT) {
if (i === splittedPath.length) {
callBackFunction();
callBackFunction(global.DEFAULT_OK_RESPONSE);
} else {