Initialization Done

This commit is contained in:
Luis Fernando Molina committed 2018-03-16 10:57:05 +01:00
1 parent ee3e91c183
commit e9fc84ee12
5 files changed
+77 -70

No files matched your search

Binary file not shown.
+15 -15
View File
@@ -1,4 +1,4 @@
exports.newInterval = function newInterval(BOT, UTILITIES, AZURE_FILE_STORAGE, DEBUG_MODULE, MARKETS_MODULE, POLONIEX_CLIENT_MODULE) {
exports.newInterval = function newInterval(BOT, UTILITIES, FILE_STORAGE, DEBUG_MODULE, MARKETS_MODULE, POLONIEX_CLIENT_MODULE) {
let bot = BOT;
const ROOT_DIR = './';
@@ -27,7 +27,7 @@
let markets;
let azureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot);
let charlyFileStorage = FILE_STORAGE.newFileStorage(bot);
let utilities = UTILITIES.newUtilities(bot);
@@ -51,7 +51,7 @@
console.log(logText);
logger.write(logText);
azureFileStorage.initialize();
charlyFileStorage.initialize();
markets = MARKETS_MODULE.newMarkets(bot);
markets.initialize(callBackFunction);
@@ -277,7 +277,7 @@ This process complements the Live Trades process and write historical trades fil
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
azureFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
function onFileReceived(text) {
@@ -333,7 +333,7 @@ This process complements the Live Trades process and write historical trades fil
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process + "/" + year + "/" + month;
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
azureFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
function onFileReceived(text) {
@@ -726,11 +726,11 @@ This process complements the Live Trades process and write historical trades fil
filePath = EXCHANGE_NAME + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPath;
utilities.createFolderIfNeeded(filePath, azureFileStorage, onFolderCreated);
utilities.createFolderIfNeeded(filePath, charlyFileStorage, onFolderCreated);
function onFolderCreated() {
azureFileStorage.createTextFile(filePath, fileName, fileContent + '\n', onFileCreated);
charlyFileStorage.createTextFile(filePath, fileName, fileContent + '\n', onFileCreated);
function onFileCreated() {
@@ -848,7 +848,7 @@ This process complements the Live Trades process and write historical trades fil
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process + "/" + year + "/" + month;
utilities.createFolderIfNeeded(reportFilePath, azureFileStorage, onFolderCreated);
utilities.createFolderIfNeeded(reportFilePath, charlyFileStorage, onFolderCreated);
function onFolderCreated() {
@@ -867,7 +867,7 @@ This process complements the Live Trades process and write historical trades fil
let fileContent = JSON.stringify(report);
azureFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onFileCreated);
charlyFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onFileCreated);
function onFileCreated() {
@@ -879,7 +879,7 @@ This process complements the Live Trades process and write historical trades fil
reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
utilities.createFolderIfNeeded(reportFilePath, azureFileStorage, onFolderCreated);
utilities.createFolderIfNeeded(reportFilePath, charlyFileStorage, onFolderCreated);
function onFolderCreated() {
@@ -898,7 +898,7 @@ This process complements the Live Trades process and write historical trades fil
let fileContent = JSON.stringify(report);
azureFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onMasterFileCreated);
charlyFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onMasterFileCreated);
function onMasterFileCreated() {
@@ -965,7 +965,7 @@ This process complements the Live Trades process and write historical trades fil
/* Lets read the main status report */
azureFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
function onFileReceived(text) {
@@ -1001,7 +1001,7 @@ This process complements the Live Trades process and write historical trades fil
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process + "/" + initialYear + "/" + paddedInitialMonth;
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
azureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportFileReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onStatusReportFileReceived, true);
function onStatusReportFileReceived(text) {
@@ -1067,7 +1067,7 @@ This process complements the Live Trades process and write historical trades fil
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
azureFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
function onFileReceived(text) {
@@ -1077,7 +1077,7 @@ This process complements the Live Trades process and write historical trades fil
let fileContent = JSON.stringify(statusReport);
azureFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onMasterFileCreated);
charlyFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onMasterFileCreated);
function onMasterFileCreated() {
+18 -18
View File
@@ -1,4 +1,4 @@
exports.newInterval = function newInterval(BOT, UTILITIES, AZURE_FILE_STORAGE, DEBUG_MODULE, MARKETS_MODULE, POLONIEX_CLIENT_MODULE) {
exports.newInterval = function newInterval(BOT, UTILITIES, FILE_STORAGE, DEBUG_MODULE, MARKETS_MODULE, POLONIEX_CLIENT_MODULE) {
let bot = BOT;
const ROOT_DIR = '../';
@@ -27,7 +27,7 @@
let markets;
let azureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot);
let charlyFileStorage = FILE_STORAGE.newFileStorage(bot);
let utilities = UTILITIES.newUtilities(bot);
@@ -51,7 +51,7 @@
console.log(logText);
logger.write(logText);
azureFileStorage.initialize();
charlyFileStorage.initialize();
markets = MARKETS_MODULE.newMarkets(bot);
markets.initialize(callBackFunction);
@@ -338,7 +338,7 @@ What is the lastFile pointer?
reportFilePath = EXCHANGE_NAME + "/Processes/" + "Poloniex-Live-Trades";
azureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true);
function onStatusReportReceived(text) {
@@ -386,7 +386,7 @@ What is the lastFile pointer?
reportFilePath = EXCHANGE_NAME + "/Processes/" + "Poloniex-Historic-Trades";
azureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true);
function onStatusReportReceived(text) {
@@ -449,7 +449,7 @@ What is the lastFile pointer?
reportFilePath = EXCHANGE_NAME + "/Processes/" + "Poloniex-Hole-Fixing" + "/" + year + "/" + month;
azureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true);
function onStatusReportReceived(text) {
@@ -606,7 +606,7 @@ What is the lastFile pointer?
filePath = EXCHANGE_NAME + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPath;
azureFileStorage.getTextFile(filePath, fileName, onNextFileReceived, true);
charlyFileStorage.getTextFile(filePath, fileName, onNextFileReceived, true);
function onNextFileReceived(text) {
@@ -846,7 +846,7 @@ What is the lastFile pointer?
filePath = EXCHANGE_NAME + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPath;
azureFileStorage.getTextFile(filePath, fileName, onNextFileReceived, true);
charlyFileStorage.getTextFile(filePath, fileName, onNextFileReceived, true);
function onNextFileReceived(text) {
@@ -1298,11 +1298,11 @@ What is the lastFile pointer?
filePath = EXCHANGE_NAME + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPath;
utilities.createFolderIfNeeded(filePath, azureFileStorage, onFolderCreated);
utilities.createFolderIfNeeded(filePath, charlyFileStorage, onFolderCreated);
function onFolderCreated() {
azureFileStorage.createTextFile(filePath, fileName, fileContent + '\n', onFileCreated);
charlyFileStorage.createTextFile(filePath, fileName, fileContent + '\n', onFileCreated);
function onFileCreated() {
@@ -1374,7 +1374,7 @@ What is the lastFile pointer?
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process + "/" + year + "/" + month;
utilities.createFolderIfNeeded(reportFilePath, azureFileStorage, onFolderCreated);
utilities.createFolderIfNeeded(reportFilePath, charlyFileStorage, onFolderCreated);
function onFolderCreated() {
@@ -1433,7 +1433,7 @@ What is the lastFile pointer?
let fileContent = JSON.stringify(report);
azureFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onFileBCreated);
charlyFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onFileBCreated);
function onFileBCreated() {
@@ -1489,7 +1489,7 @@ What is the lastFile pointer?
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
utilities.createFolderIfNeeded(reportFilePath, azureFileStorage, onFolderCreated);
utilities.createFolderIfNeeded(reportFilePath, charlyFileStorage, onFolderCreated);
function onFolderCreated() {
@@ -1520,7 +1520,7 @@ What is the lastFile pointer?
let fileContent = JSON.stringify(report);
azureFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onFileBCreated);
charlyFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onFileBCreated);
function onFileBCreated() {
@@ -1575,7 +1575,7 @@ What is the lastFile pointer?
/* Lets read the main status report */
azureFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
function onFileReceived(text) {
@@ -1611,7 +1611,7 @@ What is the lastFile pointer?
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process + "/" + initialYear + "/" + paddedInitialMonth;
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
azureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportFileReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onStatusReportFileReceived, true);
function onStatusReportFileReceived(text) {
@@ -1653,7 +1653,7 @@ What is the lastFile pointer?
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
azureFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
function onFileReceived(text) {
@@ -1673,7 +1673,7 @@ What is the lastFile pointer?
let fileContent = JSON.stringify(statusReport);
azureFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onMasterFileCreated);
charlyFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onMasterFileCreated);
function onMasterFileCreated() {
@@ -1,59 +1,68 @@
exports.newInterval = function newInterval(BOT, UTILITIES, AZURE_FILE_STORAGE, DEBUG_MODULE, MARKETS_MODULE, POLONIEX_CLIENT_MODULE) {
exports.newUserBot = function newUserBot(BOT, COMMONS, UTILITIES, DEBUG_MODULE, FILE_STORAGE, STATUS_REPORT, POLONIEX_CLIENT_MODULE) {
const FULL_LOG = true;
const LOG_FILE_CONTENT = false;
let bot = BOT;
const ROOT_DIR = './';
const GMT_SECONDS = ':00.000 GMT+0000';
const GMT_MILI_SECONDS = '.000 GMT+0000';
const MODULE_NAME = "Interval";
const LOG_INFO = true;
const MODULE_NAME = "User Bot";
const EXCHANGE_NAME = "Poloniex";
const EXCHANGE_ID = 1;
const TRADES_FOLDER_NAME = "Trades";
const GO_RANDOM = false;
const FORCE_MARKET = 2; // This allows to debug the execution of an specific market. Not intended for production.
const FORCED_INITIAL_TIME = undefined; //"2018-01-19 12:15:00.000 GMT+0000"
const logger = DEBUG_MODULE.newDebugLog();
logger.fileName = MODULE_NAME;
logger.bot = bot;
interval = {
thisObject = {
initialize: initialize,
start: start
};
let markets;
let azureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot);
let charlyFileStorage = FILE_STORAGE.newFileStorage(bot);
let utilities = UTILITIES.newUtilities(bot);
return interval;
function initialize(pYear, pMonth, callBackFunction) { // Year and Month ignored at this process.
function initialize(yearAssigend, monthAssigned, callBackFunction) {
try {
const logText = "[INFO] initialize - Entering function 'initialize' ";
console.log(logText);
logger.write(logText);
/* IMPORTANT NOTE:
azureFileStorage.initialize();
We are ignoring in this UserBot the received Year and Month. thisObject is not depending on Year / Month.
markets = MARKETS_MODULE.newMarkets(bot);
markets.initialize(callBackFunction);
*/
logger.fileName = MODULE_NAME;
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> yearAssigend = " + yearAssigend); }
if (FULL_LOG === true) { logger.write("[INFO] initialize -> monthAssigned = " + monthAssigned); }
charlyFileStorage.initialize("AACharly", onCharlyInizialized);
function onCharlyInizialized(err) {
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
if (FULL_LOG === true) { logger.write("[INFO] initialize -> onCharlyInizialized -> Initialization Succeed."); }
callBackFunction(global.DEFAULT_OK_RESPONSE);
} else {
logger.write("[ERROR] initialize -> onCharlyInizialized -> err = " + err.message);
callBackFunction(err);
}
}
} catch (err) {
const logText = "[ERROR] initialize - ' ERROR : " + err.message;
console.log(logText);
logger.write(logText);
logger.write("[ERROR] initialize -> err = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
}
@@ -64,11 +73,9 @@ We are going to generate 2 files:
A. The first one will contain all the trades of the current minute and will be store in a folder that we will create for this if it does not exist.
This file will be incomplete, since we are at the current minute and some trades will happen after we retrieve the information from the exchange,
but this is not a problem, since the second file is going to fix this. This file is only usefull for viewing a partial candle as it is being built
at the end of the chart.
at the head of the market.
B. The second file will contain all the trades of the previous minute. It will be the definitive file the system will use.
Besides that, we are going to delete the A file of the previous minute, since it is not needed anymore after the B file is there.
B. The second file will contain all the trades of the previous minute. This will override the incomplete file written a minute before.
FILE FORMAT
-----------
@@ -156,15 +163,15 @@ Array of records with this information:
filePathA = EXCHANGE_NAME + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPathA;
filePathB = EXCHANGE_NAME + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPathB;
utilities.createFolderIfNeeded(filePathA, azureFileStorage, onFolderACreated);
utilities.createFolderIfNeeded(filePathA, charlyFileStorage, onFolderACreated);
function onFolderACreated() {
utilities.createFolderIfNeeded(filePathB, azureFileStorage, onFolderBCreated);
utilities.createFolderIfNeeded(filePathB, charlyFileStorage, onFolderBCreated);
function onFolderBCreated() {
utilities.createFolderIfNeeded(reportFilePath, azureFileStorage, onFolderCreated);
utilities.createFolderIfNeeded(reportFilePath, charlyFileStorage, onFolderCreated);
function onFolderCreated() {
@@ -462,7 +469,7 @@ Array of records with this information:
fileContent = fileContent + ']';
azureFileStorage.createTextFile(filePathA, fileNameA, fileContent + '\n', onFirstFileACreated);
charlyFileStorage.createTextFile(filePathA, fileNameA, fileContent + '\n', onFirstFileACreated);
function onFirstFileACreated() {
@@ -517,7 +524,7 @@ Array of records with this information:
fileContent = fileContent + ']';
azureFileStorage.createTextFile(filePathB, fileNameB, fileContent + '\n', onFileBCreated);
charlyFileStorage.createTextFile(filePathB, fileNameB, fileContent + '\n', onFileBCreated);
function onFileBCreated() {
@@ -569,7 +576,7 @@ Array of records with this information:
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json"
azureFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
charlyFileStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
function onFileReceived(text) {
@@ -633,7 +640,7 @@ Array of records with this information:
let fileContent = JSON.stringify(report);
azureFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onReportFileCreated);
charlyFileStorage.createTextFile(reportFilePath, fileName, fileContent + '\n', onReportFileCreated);
function onReportFileCreated() {
+1 -1
View File
@@ -21,7 +21,7 @@
<Content Include="README.md" />
<Compile Include="Poloniex-Historic-Trades\Interval.js" />
<Compile Include="Poloniex-Hole-Fixing\Interval.js" />
<Compile Include="Poloniex-Live-Trades\Interval.js" />
<Compile Include="Poloniex-Live-Trades\User.bot.js" />
<Content Include="this.bot.config.json" />
</ItemGroup>
<ItemGroup>