Initialize and Commons
This commit is contained in:
1 parent
f84665a515
commit
cf09500ea5
5 files changed
+108
-25
No files matched your search
Binary file not shown.
+73
@@ -0,0 +1,73 @@
|
||||
exports.newCommons = function newCommons(BOT, DEBUG_MODULE, UTILITIES) {
|
||||
|
||||
const FULL_LOG = true;
|
||||
const LOG_FILE_CONTENT = false;
|
||||
|
||||
const MODULE_NAME = "Commons";
|
||||
|
||||
const ONE_DAY_IN_MILISECONDS = 24 * 60 * 60 * 1000;
|
||||
const GMT_SECONDS = ':00.000 GMT+0000';
|
||||
|
||||
let thisObject = {
|
||||
initializeStorage: initializeStorage
|
||||
};
|
||||
|
||||
let bot = BOT;
|
||||
|
||||
const logger = DEBUG_MODULE.newDebugLog();
|
||||
logger.fileName = MODULE_NAME;
|
||||
logger.bot = bot;
|
||||
|
||||
let utilities = UTILITIES.newUtilities(bot);
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initializeStorage(charlyFileStorage, bruceFileStorage, callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeStorage -> Entering function."); }
|
||||
|
||||
initializeBruceStorage();
|
||||
|
||||
function initializeBruceStorage() {
|
||||
|
||||
bruceFileStorage.initialize("AABruce", onBruceInizialized);
|
||||
|
||||
function onBruceInizialized(err) {
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
initializeCharlyStorage();
|
||||
|
||||
} else {
|
||||
logger.write("[ERROR] initializeStorage -> initializeBruceStorage -> onBruceInizialized -> err = " + err.message);
|
||||
callBackFunction(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initializeCharlyStorage() {
|
||||
|
||||
charlyFileStorage.initialize("AACharly", onCharlyInizialized);
|
||||
|
||||
function onCharlyInizialized(err) {
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
|
||||
} else {
|
||||
logger.write("[ERROR] initializeStorage -> initializeCharlyStorage -> onCharlyInizialized -> err = " + err.message);
|
||||
callBackFunction(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
logger.write("[ERROR] initializeStorage -> err = " + err.message);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
+29
-23
@@ -25,6 +25,8 @@
|
||||
logger.fileName = MODULE_NAME;
|
||||
logger.bot = bot;
|
||||
|
||||
const commons = COMMONS.newCommons(bot, DEBUG_MODULE, UTILITIES);
|
||||
|
||||
thisObject = {
|
||||
initialize: initialize,
|
||||
start: start
|
||||
@@ -42,44 +44,48 @@
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(yearAssigend, monthAssigned, callBackFunction) {
|
||||
function initialize(pDependencies, pMonth, pYear, callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
year = yearAssigend;
|
||||
month = monthAssigned;
|
||||
|
||||
year = pYear;
|
||||
month = pMonth;
|
||||
month = utilities.pad(month, 2); // Adding a left zero when needed.
|
||||
dependencies = pDependencies;
|
||||
|
||||
logger.fileName = MODULE_NAME + "-" + year + "-" + month;
|
||||
|
||||
const logText = "[INFO] initialize - Entering function 'initialize' " + " @ " + year + "-" + month;
|
||||
console.log(logText);
|
||||
logger.write(logText);
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> pYear = " + year); }
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> pMonth = " + month); }
|
||||
|
||||
charlyFileStorage.initialize("Charly");
|
||||
bruceFileStorage.initialize("Bruce");
|
||||
dependencies = pDependencies;
|
||||
|
||||
markets = MARKETS_MODULE.newMarkets(bot);
|
||||
markets.initialize(callBackFunction);
|
||||
commons.initializeStorage(charlyFileStorage, bruceFileStorage, onInizialized);
|
||||
|
||||
function onInizialized(err) {
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> onInizialized -> Initialization Succeed."); }
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
|
||||
} else {
|
||||
logger.write("[ERROR] initialize -> onInizialized -> 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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
This process is going to do the following:
|
||||
|
||||
Read the trades from Charly's Output and pack them into daily files with candles of one minute.
|
||||
|
||||
*/
|
||||
/*
|
||||
This process is going to do the following:
|
||||
Read the trades from Charly's Output and pack them into daily files with candles of one minute.
|
||||
*/
|
||||
|
||||
function start(callBackFunction) {
|
||||
|
||||
+4
-1
@@ -21,7 +21,10 @@
|
||||
<Content Include="package-lock.json" />
|
||||
<Content Include="package.json" />
|
||||
<Content Include="README.md" />
|
||||
<Compile Include="One-Min-Daily-Candles-Volumes\Interval.js" />
|
||||
<Compile Include="Commons.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="One-Min-Daily-Candles-Volumes\User.bot.js" />
|
||||
<Content Include="logs\Dummy File.txt" />
|
||||
<Content Include="obj\Debug\AACarol.njsproj.FileListAbsolute.txt" />
|
||||
<Content Include="obj\Debug\AACharly.njsproj.FileListAbsolute.txt" />
|
||||
|
||||
@@ -61,7 +61,8 @@
|
||||
"minor": 0
|
||||
},
|
||||
"process": "One-Min-Daily-Candles-Volumes",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
"dataSetVersion": "dataSet.V1",
|
||||
"dataSetSection": "Month"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user