From 2dc14fa8d8febdb29c085a3b937362afffe9d33e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 16 Feb 2018 22:31:45 +0100 Subject: [PATCH] Upgraded to run with AACloudPlatform --- .vs/AABruce/v15/.suo | Bin 30208 -> 39936 bytes AABruce.njsproj | 12 +- AABruce.sln | 2 +- Azure File Storage.js | 247 ----------- Azure Web Job Shutdown.js | 41 -- Debug Log.js | 144 ------- Markets.js | 252 ----------- .../Interval Executor.js | 169 -------- One-Min-Daily-Candles-Volumes/Interval.js | 11 +- One-Min-Daily-Candles-Volumes/run.js | 97 ----- Poloniex API Client.js | 406 ------------------ Utilities.js | 81 ---- this.bot.config.json | 34 ++ 13 files changed, 41 insertions(+), 1455 deletions(-) delete mode 100644 Azure File Storage.js delete mode 100644 Azure Web Job Shutdown.js delete mode 100644 Debug Log.js delete mode 100644 Markets.js delete mode 100644 One-Min-Daily-Candles-Volumes/Interval Executor.js delete mode 100644 One-Min-Daily-Candles-Volumes/run.js delete mode 100644 Poloniex API Client.js delete mode 100644 Utilities.js create mode 100644 this.bot.config.json diff --git a/.vs/AABruce/v15/.suo b/.vs/AABruce/v15/.suo index a8885d3c4a218ab3e0f919f261ed1dd7a5dd10ae..93e15830db37f69214c15e08b6793b2d2a9486f2 100644 GIT binary patch literal 39936 zcmeHQd30OF)qgUCtrSR0fTmxGo2C>3lBHPQ5+{wkH7PN6<0PcuE{gQ*$jFkBWGBw@ zl~O1zrIao}pbKj$g+MpDr5q?-`1-Yfl+)#$9{%Wob2z0foN`Y8>G`(g`~BX$v7Vmv zHtE@p5{=LG%$pg_o#oD*d+*Gf_rh;|9mD3FI0fd|6^LdJL zmi~P7*s)`bJ_Uea!_`p_Y*n)OD=5uMzmkEUQ)W4ouH6O7lDRQ|kHfF-c>cAp`ipM%7e0M^4QpE>@Z9wFP$c2A)mS@eerDAvOK%hG4!e>bAu0&t7} z?a14?M3i$ny#F(HpdRL&UapsEOuh(lX9LI=Bu=KU#q&D=Zv`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z7>{HU@%gy)dJZ zz+ETksGw-)_9?F%3cERk&g2^c>2ar}@t1)!E;t&J-JR;o$H-++4xW!=dn2xN<50V+V?+md|iK-41p-3+;|Q zg2<;#zPIWt4xfweB@FQq2INA4mOzG_-t#(NdRp#CI~*4+Qv>cNY_{lfmc}O8D^L?F z(d;%i3rZTXFqTGAN6km93t83r)re56B68W7xV0s4H@n`zDf-lkw4R6@FY?iN#+g(?S;Y3pnLG~WY^c1f436bg z2#Qfu@`cE0VsI~~PAM?DS0Zk#YE}qz=@227GIUb|_iT9YMwGxzi4;qxsq$7tpDs_H zkbFVkGwKhGG&&!xztfkNX7|IR>G11BqAtkxv%{=iUI=g=cGWJnlicm{as#6dp)4p) z&6c(abi2@k8z8u4i0ff)%M}AB+bKV^qotR%4dzR|PhqC$KF*x?4OE&-!)vPa^d{%3 zs^sqK1`ckI1;(7k3P>6OB#!{K9;32$*ICfl2QcPzgk2(t`RAUOzQuDj99!9wg2%4G z<{x&Jks&d)=rndCT^cx&V5}ko=_aT`AY z{i^pu{(B>_*OzZ4dAj@<`vqe_L08rsZZ(MDuS&ccEA+XJb)?R8Ylij;FX&Q@Bpr4hqB38qy@lh_uuagz93I$(>m=k|hOhT+& z*(*m(!e2Q;CEJMK8s%5X*1^TrJm~YeV6xMaMD=iH}GpJ|&0oJHU2arAv{rFbQLwB@pu4pPB~~=HW941m1z^ zUKc;BJSI&?Yrq#sgd3yjI#m~Z*SC@Mz@H-)Exnw{|0uUz4h`<*8i_%9Pa&KdIvDPl zhN%GuNF#cAQz)JD50sP2ye{xf*wLE=Xc?}CkB21KT49z)2iv34*i6(W7eeTlhGb~Dq$ln^px�K diff --git a/AABruce.njsproj b/AABruce.njsproj index 4a9c6ebdc..8b7ed3f48 100644 --- a/AABruce.njsproj +++ b/AABruce.njsproj @@ -6,7 +6,8 @@ {045bbaef-3c35-4017-8458-e46aef438790} ShowAllFiles - One-Min-Daily-Candles-Volumes\run.js + + C:\Users\Luis\source\repos\AABruce\One-Min-Daily-Candles-Volumes . {3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD} @@ -19,18 +20,11 @@ - - - - - - - - + diff --git a/AABruce.sln b/AABruce.sln index e5011cdca..0f8bf8f28 100644 --- a/AABruce.sln +++ b/AABruce.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.10 +VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}") = "AABruce", "AABruce.njsproj", "{045BBAEF-3C35-4017-8458-E46AEF438790}" EndProject diff --git a/Azure File Storage.js b/Azure File Storage.js deleted file mode 100644 index dcb2f6c89..000000000 --- a/Azure File Storage.js +++ /dev/null @@ -1,247 +0,0 @@ - -exports.newAzureFileStorage = function newAzureFileStorage(BOT) { - - let bot = BOT; - const ROOT_DIR = '../'; - - const MODULE_NAME = "Azure File Storage"; - - var fs = require('fs'); - var util = require('util'); - var guid = require('node-uuid'); - var crypto = require('crypto'); - var storage = require('azure-storage'); - - const DEBUG_MODULE = require('./Debug Log'); - const logger = DEBUG_MODULE.newDebugLog(); - logger.fileName = MODULE_NAME; - logger.bot = bot; - - const shareName = 'data'; - let dataOwner; - - let azureFileStorage = { - initialize: initialize, - createFolder: createFolder, - createTextFile: createTextFile, - getTextFile: getTextFile, - listFilesAndFolders: listFilesAndFolders - }; - - let fileService; - - return azureFileStorage; - - - function initialize(dataOwnerBotName) { - - try { - - if (dataOwnerBotName === undefined) { - - dataOwner = bot.name; - - } else { - - dataOwner = dataOwnerBotName; - - } - - fileService = storage.createFileService(readConfig().connectionString); - - } - catch (err) { - const logText = "[ERROR] 'initialize' - ERROR : " + err.message; - logger.write(logText); - } - } - - function readConfig() { - - try { - - return JSON.parse(fs.readFileSync(ROOT_DIR + dataOwner + '.azure.storage.connstring', 'utf8')); - - } - catch (err) { - const logText = "[ERROR] 'readConfig' - ERROR : " + err.message; - logger.write(logText); - } - - } - - function createFolder(folderPath, callBackFunction) { - - try { - - fileService.createDirectoryIfNotExists(shareName, folderPath, onFolderCreated); - - function onFolderCreated(err) { - - if (err) { - - const logText = "[ERROR] createFolder - onFolderCreated ' ERROR = " + err.message + " SHARE NAME = " + shareName + " FOLDER PATH = " + folderPath; - console.log(logText); - logger.write(logText); - - } - - callBackFunction(); - - } - - } - catch (err) { - const logText = "[ERROR] 'createFolder' - ERROR : " + err.message; - logger.write(logText); - } - - } - - function createTextFile(folderPath, fileName, fileContent, callBackFunction) { - - try { - - fileService.createFileFromText(shareName, folderPath, fileName, fileContent, onFileCreated); - - function onFileCreated(err, result, response) { - - if (err) { - - const logText = "[WARN] createTextFile - onFileCreated ' ERROR = " + err.message + " SHARE NAME = " + shareName + " FOLDER PATH = " + folderPath + " FILE NAME = " + fileName; - console.log(logText); - logger.write(logText); - - if (err.message.indexOf("The server is busy") > 0) { - - fileService.createFileFromText(shareName, folderPath, fileName, fileContent, onFileCreatedSecondTry); - - function onFileCreatedSecondTry(err) { - - if (err) { - - const logText = "[ERROR] createTextFile - onFileCreated - onFileCreatedSecondTry : File not created. Giving Up.' ERROR = " + err.message + " SHARE NAME = " + shareName + " FOLDER PATH = " + folderPath + " FILE NAME = " + fileName; - console.log(logText); - logger.write(logText); - - } else { - - const logText = "[INFO] createTextFile - onFileCreated - onFileCreatedSecondTry ' : File succesfully created on second try. SHARE NAME = " + shareName + " FOLDER PATH = " + folderPath + " FILE NAME = " + fileName; - console.log(logText); - logger.write(logText); - - } - } - } - } - - callBackFunction(); - } - - } - catch (err) { - const logText = "[ERROR] 'createTextFile' - ERROR : " + err.message; - logger.write(logText); - } - - } - - function getTextFile(folderPath, fileName, callBackFunction, ignoreNotFound) { - - try { - - fileService.getFileToText(shareName, folderPath, fileName, undefined, onFileReceived); - - function onFileReceived(err, text, response) { - - if (err) { - - if (ignoreNotFound === undefined) { - - const logText = "[ERROR] getTextFile - onFileReceived ' ERROR = " + err.message + " SHARE NAME = " + shareName + " FOLDER PATH = " + folderPath + " FILE NAME = " + fileName; - console.log(logText); - logger.write(logText); - - } - - text = undefined; - - } - - callBackFunction(text); - } - - } - catch (err) { - const logText = "[ERROR] 'getTextFile' - ERROR : " + err.message; - logger.write(logText); - } - - } - - function listFilesAndFolders(folderPath, callBackFunction) { - - try { - - let items = { - files: [], - folders: [] - }; - - /* - * @param { object } [options] The request options. - * @param { int } [options.maxResults] Specifies the maximum number of folders to return per call to Azure ServiceClient. - * This does NOT affect list size returned by this function. (maximum: 5000) - * @param { LocationMode } [options.locationMode] Specifies the location mode used to decide which location the request should be sent to. - * Please see StorageUtilities.LocationMode for the possible values. - * @param { int } [options.timeoutIntervalInMs] The server timeout interval, in milliseconds, to use for the request. - * @param { int } [options.maximumExecutionTimeInMs] The maximum execution time, in milliseconds, across all potential retries, to use when making this request. - * The maximum execution time interval begins at the time that the client begins building the request.The maximum - * execution time is checked intermittently while performing requests, and before executing retries. - * @param { string } [options.clientRequestId] A string that represents the client request ID with a 1KB character limit. - * @param { bool } [options.useNagleAlgorithm] Determines whether the Nagle al - */ - - let options = { - maxResults: 500 - }; - - fileService.listFilesAndDirectoriesSegmented(shareName, folderPath, null, options, onFilesAndFoldersReceived); - - - function onFilesAndFoldersReceived(error, result) { - - try { - - if (error) { - - const logText = "[ERROR] 'listFilesAndFolders - onFilesAndFoldersReceived' - ERROR RECEIVED : " + error; - logger.write(logText); - - callBackFunction(items); - - } else { - - items.files.push.apply(items.files, result.entries.files); - items.folders.push.apply(items.folders, result.entries.directories); - - callBackFunction(items); - - } - - } - catch (err) { - const logText = "[ERROR] 'listFilesAndFolders - onFilesAndFoldersReceived' - ERROR : " + err.message; - logger.write(logText); - } - - } - - } - catch (err) { - const logText = "[ERROR] 'listFilesAndFolders' - ERROR : " + err.message; - logger.write(logText); - } - } - -}; \ No newline at end of file diff --git a/Azure Web Job Shutdown.js b/Azure Web Job Shutdown.js deleted file mode 100644 index 22ed305de..000000000 --- a/Azure Web Job Shutdown.js +++ /dev/null @@ -1,41 +0,0 @@ - -exports.newShutdownEvent = function newShutdownEvent(BOT) { - - let bot = BOT; - const ROOT_DIR = '../'; - - const MODULE_NAME = "Azure Web Job Shutdown"; - - - const DEBUG_MODULE = require('./Debug Log'); - const logger = DEBUG_MODULE.newDebugLog(); - logger.fileName = MODULE_NAME; - logger.bot = bot; - - let shutdownEvent = { - isShuttingDown: isShuttingDown - }; - - return shutdownEvent; - - - function isShuttingDown() { - - let filePath = process.env.WEBJOBS_SHUTDOWN_FILE; - - let fs = require('fs'); - - if (fs.existsSync(filePath)) { - return true; - } - else - { - return false; - } - - } - - - - -} \ No newline at end of file diff --git a/Debug Log.js b/Debug Log.js deleted file mode 100644 index fc543e5d7..000000000 --- a/Debug Log.js +++ /dev/null @@ -1,144 +0,0 @@ - - - -exports.newDebugLog = function newDebugLog() { - - - const MODULE_NAME = "Debug Log"; - const fileSystem = require('fs'); - - const currentDate = new Date(); - const dateString = currentDate.getUTCFullYear() + '-' + pad(currentDate.getUTCMonth() + 1, 2) + '-' + pad(currentDate.getUTCDate(), 2) + '-' + pad(currentDate.getUTCHours(), 2) + '-' + pad(currentDate.getUTCMinutes(), 2); - const randomId = parseInt(Math.random() * 1000000); - - let fileNumber = 1; - let messageId = 0; - let firstCall = true; - let folderPath; - - debugLog = { - bot: undefined, - fileName: undefined, - write: write - }; - - - - return debugLog; - - - function createFolders() { - - try { - - folderPath = debugLog.bot.devTeam; - - createFolderSync(folderPath); - - folderPath = debugLog.bot.devTeam + "/" + debugLog.bot.type; - - createFolderSync(folderPath); - - folderPath = debugLog.bot.devTeam + "/" + debugLog.bot.type + "/" + debugLog.bot.name; - - createFolderSync(folderPath); - - folderPath = debugLog.bot.devTeam + "/" + debugLog.bot.type + "/" + debugLog.bot.name + "/" + debugLog.bot.version; - - createFolderSync(folderPath); - - folderPath = debugLog.bot.devTeam + "/" + debugLog.bot.type + "/" + debugLog.bot.name + "/" + debugLog.bot.version + "/" + debugLog.bot.process; - - createFolderSync(folderPath); - - firstCall = false; - - } - catch (err) { - console.log("Error trying to create the folders needed. Error: " + err); - } - - - } - - - function write(Message) { - - if (firstCall === true) { - - createFolders(); - - } - - let filePath = getCurrentLogFile(folderPath + "/" + dateString + "---" + randomId + "---", this.fileName); - - let newDate = new Date(); - newDate = newDate.toISOString(); - - messageId++; - - try { - - fileSystem.appendFileSync(filePath, '\r\n' + newDate + " " + messageId + " " + Message); - - } - catch (err) { - console.log("Error trying to log info into a file. File: " + filePath + " Error:" + err); - } - } - - - function createFolderSync(name) { - try { - fileSystem.mkdirSync( '../logs/' + name) - } catch (err) { - if (err.code !== 'EEXIST') throw err - } - } - - function getCurrentLogFile(relativePath, fileName) { - - let filePath; - let stats; - let i; - - try { - for (i = 1; i < 1000000; i++) { - - filePath = '../logs/' + relativePath + i + "." + fileName + '.log'; - stats = fileSystem.statSync(filePath); - } - } - catch (err) { - - if (i > 1) { - - filePath = '../logs/' + relativePath + (i - 1) + "." + fileName + '.log'; - - stats = fileSystem.statSync(filePath); - const fileSizeInBytes = stats.size; - - if (fileSizeInBytes > 10240000) { - - filePath = '../logs/' + relativePath + i + "." + fileName + '.log'; - } - - return filePath; - - } else { - - return filePath; - - } - - } - - } - - function pad(str, max) { - str = str.toString(); - return str.length < max ? pad("0" + str, max) : str; - } - -}; - diff --git a/Markets.js b/Markets.js deleted file mode 100644 index 54ba5512d..000000000 --- a/Markets.js +++ /dev/null @@ -1,252 +0,0 @@ -/* This business logic module is responsible for Markets and Assets. */ - - -exports.newMarkets = function newMarkets(BOT) { - - let bot = BOT; - const ROOT_DIR = '../'; - - const MODULE_NAME = "Markets"; - - const FOLDER_PATHS = 'data'; - const MARKETS_FOLDER_NAME = "other-files"; - - const DEBUG_MODULE = require('./Debug Log'); - const logger = DEBUG_MODULE.newDebugLog(); - logger.fileName = MODULE_NAME; - logger.bot = bot; - - const EXCHANGE_ID = 1; - const fileName = "Markets_" + EXCHANGE_ID + ".json"; - - const DATA_OWNER_BOT_NAME = "Carol" - - const markets = { - DISABLED: 0, - ENABLED: 1, - getMarketsByExchange: getMarketsByExchange, - getExistingOrNewMarketId: getExistingOrNewMarketId, - createNewAsset: createNewAsset, - createNewMarket: createNewMarket, - disableMarket: disableMarket, - initialize: initialize - }; - - //const dataLayer = DATA_LAYER_MODULE.newDataLayer(); - - let marketsArray; - - const AZURE_FILE_STORAGE = require('./Azure File Storage'); - let azureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); - - return markets; - - - function initialize(callBackFunction) { - - azureFileStorage.initialize(DATA_OWNER_BOT_NAME); - - try { - - azureFileStorage.getTextFile(MARKETS_FOLDER_NAME, fileName, onFileRead); - - function onFileRead(text) { - - try { - - var fileString = text; - let cleanString = fileString; - - /* Dont know why but sometimes files comes with a first characater that is not supposed to be there and you can not see it at the file opened with notepad */ - - if (fileString[0] !== "[") { - - cleanString = ''; - - for (let i = 1; i < fileString.length; i++) { - cleanString = cleanString + fileString[i]; - } - } - - marketsArray = JSON.parse(cleanString); - callBackFunction(); - - } - catch (err) { - const logText = "[ERROR] initialize - onFileRead ' ERROR : " + err.message + " File: " + fileName; - console.log(logText); - logger.write(logText); - } - - } - } - catch (err) { - const logText = "[ERROR] initialize - ' ERROR : " + err.message + " File Not Found: " + fileName; - console.log(logText); - logger.write(logText); - } - - - } - - - - function getMarketsByExchange(exchangeId, callBackFunction) { - - try { - - // TODO: Currently the exchange Id is ignored as the class is still working with only one exchange. We must fix this. - - callBackFunction(JSON.stringify(marketsArray)); - - - } catch (err) { - - const logText = "[ERROR] getMarketsByExchange - ' ERROR : " + err.message; - console.log(logText); - logger.write(logText); - - } - - } - - - function getExistingOrNewMarketId(marketName, market, exchangeId, callBackFunction) { - - // TODO: At this function is missing the following: If a market does not exists, it must be greated, and Id generated and returned. We automatically discover new markets when this function is called with a market that didn-t previuously existed. - - try { - - for (let i = 0; i < marketsArray.length; i++) { - - if (marketsArray[i][1] + "_" + marketsArray[i][2] === marketName) { - - callBackFunction(marketName, market, marketsArray[i][0]); - return; - - } - } - - - } catch (err) { - - const logText = "[ERROR] getExistingOrNewMarketId - ' ERROR : " + err.message + " marketId = " + marketId + " idAssetA = " + idAssetA + " idAssetB = " + idAssetB; - console.log(logText); - logger.write(logText); - - } - - } - - - function createNewAsset(assetCode, callBackFunction) { - - // TODO: Upgrade this function in order to update the file containing all assets, not the database that will be deprecated. - - try { - - dataLayer.newAsset(assetCode, onIdReady); - - function onIdReady(resultSet) { - - try { - - callBackFunction(resultSet); - resultSet = []; - - } catch (err) { - - const logText = "[ERROR] createNewAsset - onIdReady ' ERROR : " + err.message; - console.log(logText); - logger.write(logText); - - } - } - - } catch (err) { - - const logText = "[ERROR] createNewAsset - ' ERROR : " + err.message; - console.log(logText); - logger.write(logText); - - } - - } - - - - function createNewMarket(exchangeId, idAssetA, idAssetB, callBackFunction) { - - // TODO: Upgrade this function in order to update the file containing all markets, not the database that will be deprecated. - - try { - - dataLayer.newMarket(exchangeId, idAssetA, idAssetB, onIdReady); - - function onIdReady(resultSet) { - - try { - - callBackFunction(resultSet); - - } catch (err) { - - const logText = "[ERROR] createNewMarket - onIdReady ' ERROR : " + err.message; - console.log(logText); - logger.write(logText); - } - } - - } catch (err) { - - const logText = "[ERROR] createNewMarket - ' ERROR : " + err.message; - console.log(logText); - logger.write(logText); - } - } - - - function disableMarket(exchangeId, marketId, callBackFunction) { - - // This function puts the requested market in a DISABLED status. - - // TODO: Currently the exchangeId is ignored. - - try { - - for (let i = 0; i < marketsArray.length; i++) { - - if (marketsArray[i][0] === marketId) { - - marketsArray[i][3] = markets.DISABLED; - break; - - } - - } - - azureFileStorage.createTextFile(MARKETS_FOLDER_NAME, fileName, JSON.stringify(marketsArray), onFileReplaced); - - function onFileReplaced() { - - try { - - callBackFunction(); - - } catch (err) { - - const logText = "[ERROR] disableMarket - onFileReplaced ' ERROR : " + err.message; - console.log(logText); - logger.write(logText); - } - } - - } catch (err) { - - const logText = "[ERROR] disableMarket - ' ERROR : " + err.message; - console.log(logText); - logger.write(logText); - } - } - -}; \ No newline at end of file diff --git a/One-Min-Daily-Candles-Volumes/Interval Executor.js b/One-Min-Daily-Candles-Volumes/Interval Executor.js deleted file mode 100644 index c21c761ff..000000000 --- a/One-Min-Daily-Candles-Volumes/Interval Executor.js +++ /dev/null @@ -1,169 +0,0 @@ -exports.newIntervalExecutor = function newIntervalExecutor(BOT) { - - let bot = BOT; - const ROOT_DIR = '../'; - - const INTERVAL_LAPSE = 10 * 1000; - - const MODULE_NAME = "Interval Executor"; - const LOG_INFO = true; - - const INTERVAL_MODULE = require('./Interval'); - - const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log'); - const logger = DEBUG_MODULE.newDebugLog(); - logger.fileName = MODULE_NAME; - logger.bot = bot; - - const INTERVAL_MAX_LOOPS = -1; // -1 for infinite loop. - - poloniexHoleFixing = { - initialize: initialize, - start: start - }; - - const SHUTDOWN_EVENT = require(ROOT_DIR + 'Azure Web Job Shutdown'); - let shutdownEvent = SHUTDOWN_EVENT.newShutdownEvent(bot); - - const UTILITIES = require(ROOT_DIR + 'Utilities'); - let utilities = UTILITIES.newUtilities(bot); - - let year; - let month; - - return poloniexHoleFixing; - - function initialize(yearAssigend, monthAssigned, callBackFunction) { - - try { - - year = yearAssigend; - month = monthAssigned; - - month = utilities.pad(month, 2); // Adding a left zero when needed. - - logger.fileName = MODULE_NAME + "-" + year + "-" + month; - - const logText = "[INFO] initialize - Entering function 'initialize' " + " @ " + year + "-" + month; - console.log(logText); - logger.write(logText); - - callBackFunction(); - - } catch (err) { - - const logText = "[ERROR] initialize - ' ERROR : " + err.message; - console.log(logText); - logger.write(logText); - - } - } - - - function start() { - - try { - - if (LOG_INFO === true) { - logger.write("[INFO] Entering function 'start', with year = " + year + " and month = " + month); - } - - let intervalId; - - if (INTERVAL_MAX_LOOPS === 0) { - - intervalId = setInterval(startNewInterval, INTERVAL_LAPSE); - - } - - let intervalLoopCounter = 0; - - startNewInterval(); // First, inmadiate run. - - function startNewInterval() { - - try { - - if (LOG_INFO === true) { - - if (INTERVAL_MAX_LOOPS !== 0) { - - logger.write("[INFO] Entering function 'startNewInterval', next execution inmediately after the current Interval finishes."); - - } else { - - logger.write("[INFO] Entering function 'startNewInterval', next execution in " + INTERVAL_LAPSE / 1000 / 60 + " minutes."); - - } - - } - - - if (shutdownEvent.isShuttingDown() === false) { - - let fileProcessingInterval = INTERVAL_MODULE.newInterval(bot); - - fileProcessingInterval.initialize(year, month, onReadyToStart); - - function onReadyToStart() { - - fileProcessingInterval.start(loopControl); - - } - - } - else { - - clearInterval(intervalId); - - const logText = "[INFO] requestNewData - Terminating Set Interval - About to exit gracefully the process. "; - console.log(logText); - logger.write(logText); - - } - - } - catch (err) { - const logText = "[ERROR] 'startNewInterval' - ERROR : " + err.message; - logger.write(logText); - } - } - - function loopControl(moreIntervalExecutionsNeeded) { - - if (moreIntervalExecutionsNeeded === true) { - - intervalLoopCounter++; - - if (intervalLoopCounter === INTERVAL_MAX_LOOPS) { - - const logText = "[WARN] 'INTERVAL_MAX_LOOPS' reached. Stopping execution. "; - logger.write(logText); - - } else { - - const logText = "[WARN] 'loopControl'. Staring new Interval. "; - logger.write(logText); - - setTimeout(startNewInterval, INTERVAL_LAPSE);// Looped Execution. - - } - - } else { - - logger.write("[WARN] Received the signal from last Interval execution to not call it anymore. Stopping execution. "); - - } - - } - - } - catch (err) { - const logText = "[ERROR] 'Start' - ERROR : " + err.message; - logger.write(logText); - } - } -}; - - - diff --git a/One-Min-Daily-Candles-Volumes/Interval.js b/One-Min-Daily-Candles-Volumes/Interval.js index a390644f0..5da61c15d 100644 --- a/One-Min-Daily-Candles-Volumes/Interval.js +++ b/One-Min-Daily-Candles-Volumes/Interval.js @@ -1,4 +1,4 @@ -exports.newInterval = function newInterval(BOT) { +exports.newInterval = function newInterval(BOT, UTILITIES, AZURE_FILE_STORAGE, DEBUG_MODULE, MARKETS_MODULE, POLONIEX_CLIENT_MODULE) { let bot = BOT; const ROOT_DIR = '../'; @@ -23,9 +23,6 @@ const GO_RANDOM = false; const FORCE_MARKET = 2; // This allows to debug the execution of an specific market. Not intended for production. - const MARKETS_MODULE = require(ROOT_DIR + 'Markets'); - - const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log'); const logger = DEBUG_MODULE.newDebugLog(); logger.fileName = MODULE_NAME; logger.bot = bot; @@ -37,11 +34,9 @@ let markets; - const AZURE_FILE_STORAGE = require(ROOT_DIR + 'Azure File Storage'); let charlyAzureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); let bruceAzureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); - const UTILITIES = require(ROOT_DIR + 'Utilities'); let utilities = UTILITIES.newUtilities(bot); let year; @@ -289,7 +284,7 @@ Read the trades from Charly's Output and pack them into daily files with candles */ - reportFilePath = EXCHANGE_NAME + "/Processes/" + "Historic-Trades"; + reportFilePath = EXCHANGE_NAME + "/Processes/" + "Poloniex-Historic-Trades"; charlyAzureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true); @@ -335,7 +330,7 @@ Read the trades from Charly's Output and pack them into daily files with candles */ - reportFilePath = EXCHANGE_NAME + "/Processes/" + "Hole-Fixing" + "/" + year + "/" + month; + reportFilePath = EXCHANGE_NAME + "/Processes/" + "Poloniex-Hole-Fixing" + "/" + year + "/" + month; charlyAzureFileStorage.getTextFile(reportFilePath, fileName, onStatusReportReceived, true); diff --git a/One-Min-Daily-Candles-Volumes/run.js b/One-Min-Daily-Candles-Volumes/run.js deleted file mode 100644 index b56ac1c24..000000000 --- a/One-Min-Daily-Candles-Volumes/run.js +++ /dev/null @@ -1,97 +0,0 @@ - -let bot = { - name: "Bruce", - process: "One-Min-Daily-Candles-Volumes", - type: "Indicator", - version: "1.0.0", - devTeam: "AA Masters" -}; - -const ROOT_DIR = '../'; - -const MODULE_NAME = "run"; - -const START_ALL_MONTHS = false; -const START_ONE_MONTH = true; - -const INTERVAL_EXECUTOR_MODULE = require('./Interval Executor'); - -const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log'); -const logger = DEBUG_MODULE.newDebugLog(); -logger.fileName = MODULE_NAME; -logger.bot = bot; - -process.on('uncaughtException', function (err) { - logger.write('uncaughtException - ' + err.message); -}); - - -process.on('unhandledRejection', (reason, p) => { - logger.write("Unhandled Rejection at: Promise " + JSON.stringify(p) + " reason: " + reason); -}); - - -process.on('exit', function (code) { - logger.write('About to exit with code:' + code); -}); - - -try { - if (START_ALL_MONTHS === true) { - - for (let year = 2018; year > 2014; year--) { - - for (let month = 12; month > 0; month--) { - - let timeDelay = Math.random() * 10 * 1000; // We introduce a short delay so as to not overload the machine. - - setTimeout(startProcess, timeDelay); - - function startProcess() { - - const newIntervalExecutor = INTERVAL_EXECUTOR_MODULE.newIntervalExecutor(bot); - - newIntervalExecutor.initialize(year, month, onInitializeReady); - - function onInitializeReady() { - - newIntervalExecutor.start(); - - } - - } - - } - - } - - } - - - if (START_ONE_MONTH === true) { - - startProcess(); - - function startProcess() { - - const newIntervalExecutor = INTERVAL_EXECUTOR_MODULE.newIntervalExecutor(bot); - - let month = 2; - let year = 2018; - - newIntervalExecutor.initialize(year, month, onInitializeReady); - - function onInitializeReady() { - - newIntervalExecutor.start(); - - } - } - } - - -} catch (err) { - console.log(err.message); - logger.write(err.message); -} - diff --git a/Poloniex API Client.js b/Poloniex API Client.js deleted file mode 100644 index d7e74a657..000000000 --- a/Poloniex API Client.js +++ /dev/null @@ -1,406 +0,0 @@ -module.exports = (function () { - 'use strict'; - - // Module dependencies - var crypto = require('crypto'), - request = require('request'), - nonce = require('nonce')(); - - // Constants - var version = '0.0.8', - PUBLIC_API_URL = 'https://poloniex.com/public', - PRIVATE_API_URL = 'https://poloniex.com/tradingApi', - USER_AGENT = 'poloniex.js ' + version; - //USER_AGENT = 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0' - - // Helper methods - function joinCurrencies(currencyA, currencyB) { - // If only one arg, then return the first - if (typeof currencyB !== 'string') { - return currencyA; - } - - return currencyA + '_' + currencyB; - } - - // Constructor - function Poloniex(key, secret) { - // Generate headers signed by this user's key and secret. - // The secret is encapsulated and never exposed - this._getPrivateHeaders = function (parameters) { - var paramString, signature; - - if (!key || !secret) { - throw 'Poloniex: Error. API key and secret required'; - } - - // Convert to `arg1=foo&arg2=bar` - paramString = Object.keys(parameters).map(function (param) { - return encodeURIComponent(param) + '=' + encodeURIComponent(parameters[param]); - }).join('&'); - - signature = crypto.createHmac('sha512', secret).update(paramString).digest('hex'); - - return { - Key: key, - Sign: signature - }; - }; - } - - // Currently, this fails with `Error: CERT_UNTRUSTED` - // Poloniex.STRICT_SSL can be set to `false` to avoid this. Use with caution. - // Will be removed in future, once this is resolved. - Poloniex.STRICT_SSL = true; - - // Customisable user agent string - Poloniex.USER_AGENT = USER_AGENT; - - // Prototype - Poloniex.prototype = { - constructor: Poloniex, - - // Make an API request - _request: function (options, callback) { - if (!('headers' in options)) { - options.headers = {}; - } - - options.json = true; - options.headers['User-Agent'] = Poloniex.USER_AGENT; - options.strictSSL = Poloniex.STRICT_SSL; - - request(options, function (err, response, body) { - // Empty response - if (!err && (typeof body === 'undefined' || body === null)) { - err = 'Empty response'; - } - - callback(err, body); - }); - - return this; - }, - - // Make a public API request - _public: function (command, parameters, callback) { - var options; - - if (typeof parameters === 'function') { - callback = parameters; - parameters = {}; - } - - parameters || (parameters = {}); - parameters.command = command; - options = { - method: 'GET', - url: PUBLIC_API_URL, - qs: parameters - }; - - options.qs.command = command; - return this._request(options, callback); - }, - - // Make a private API request - _private: function (command, parameters, callback) { - var options; - - if (typeof parameters === 'function') { - callback = parameters; - parameters = {}; - } - - parameters || (parameters = {}); - parameters.command = command; - parameters.nonce = nonce(); - - options = { - method: 'POST', - url: PRIVATE_API_URL, - form: parameters, - headers: this._getPrivateHeaders(parameters) - }; - - return this._request(options, callback); - }, - - ///// - // PUBLIC METHODS - - returnTicker: function (callback) { - return this._public('returnTicker', callback); - }, - - return24hVolume: function (callback) { - return this._public('return24hVolume', callback); - }, - - returnOrderBook: function (currencyA, currencyB, depth, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB), - depth: depth - }; - - return this._public('returnOrderBook', parameters, callback); - }, - - returnOrderBooks: function (depth, callback) { - var parameters = { - currencyPair: 'all', - depth: depth - }; - - return this._public('returnOrderBook', parameters, callback); - }, - - returnPublicTradeHistory: function (currencyA, currencyB, start, end, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB), - start: start, - end: end - }; - - return this._public('returnTradeHistory', parameters, callback); - }, - - returnChartData: function (currencyA, currencyB, period, start, end, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB), - period: period, - start: start, - end: end - }; - - return this._public('returnChartData', parameters, callback); - }, - - returnCurrencies: function (callback) { - return this._public('returnCurrencies', callback); - }, - - returnLoanOrders: function (currency, callback) { - return this._public('returnLoanOrders', { currency: currency }, callback); - }, - - ///// - // PRIVATE METHODS - - returnBalances: function (callback) { - return this._private('returnBalances', {}, callback); - }, - - returnCompleteBalances: function (callback) { - return this._private('returnCompleteBalances', {}, callback); - }, - - returnDepositAddresses: function (callback) { - return this._private('returnDepositAddresses', {}, callback); - }, - - generateNewAddress: function (currency, callback) { - return this._private('returnDepositsWithdrawals', { currency: currency }, callback); - }, - - returnDepositsWithdrawals: function (start, end, callback) { - return this._private('returnDepositsWithdrawals', { start: start, end: end }, callback); - }, - - returnOpenOrders: function (currencyA, currencyB, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB) - }; - - return this._private('returnOpenOrders', parameters, callback); - }, - - returnTradeHistory: function (currencyA, currencyB, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB) - }; - - return this._private('returnTradeHistory', parameters, callback); - }, - - returnOrderTrades: function (orderNumber, callback) { - var parameters = { - orderNumber: orderNumber - }; - - return this._private('returnOrderTrades', parameters, callback); - }, - - buy: function (currencyA, currencyB, rate, amount, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB), - rate: rate, - amount: amount - }; - - return this._private('buy', parameters, callback); - }, - - sell: function (currencyA, currencyB, rate, amount, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB), - rate: rate, - amount: amount - }; - - return this._private('sell', parameters, callback); - }, - - cancelOrder: function (currencyA, currencyB, orderNumber, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB), - orderNumber: orderNumber - }; - - return this._private('cancelOrder', parameters, callback); - }, - - moveOrder: function (orderNumber, rate, amount, callback) { - var parameters = { - orderNumber: orderNumber, - rate: rate, - amount: amount ? amount : null - }; - - return this._private('moveOrder', parameters, callback); - }, - - withdraw: function (currency, amount, address, callback) { - var parameters = { - currency: currency, - amount: amount, - address: address - }; - - return this._private('withdraw', parameters, callback); - }, - - returnFeeInfo: function (callback) { - return this._private('returnFeeInfo', {}, callback); - }, - - returnAvailableAccountBalances: function (account, callback) { - var options = {}; - if (account) { - options.account = account; - } - return this._private('returnAvailableAccountBalances', options, callback); - }, - - returnTradableBalances: function (callback) { - return this._private('returnTradableBalances', {}, callback); - }, - - transferBalance: function (currency, amount, fromAccount, toAccount, callback) { - var parameters = { - currency: currency, - amount: amount, - fromAccount: fromAccount, - toAccount: toAccount - }; - - return this._private('transferBalance', parameters, callback); - }, - - returnMarginAccountSummary: function (callback) { - return this._private('returnMarginAccountSummary', {}, callback); - }, - - marginBuy: function (currencyA, currencyB, rate, amount, lendingRate, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB), - rate: rate, - amount: amount, - lendingRate: lendingRate ? lendingRate : null - }; - - return this._private('marginBuy', parameters, callback); - }, - - marginSell: function (currencyA, currencyB, rate, amount, lendingRate, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB), - rate: rate, - amount: amount, - lendingRate: lendingRate ? lendingRate : null - }; - - return this._private('marginSell', parameters, callback); - }, - - getMarginPosition: function (currencyA, currencyB, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB) - }; - - return this._private('getMarginPosition', parameters, callback); - }, - - closeMarginPosition: function (currencyA, currencyB, callback) { - var parameters = { - currencyPair: joinCurrencies(currencyA, currencyB) - }; - - return this._private('closeMarginPosition', parameters, callback); - }, - - createLoanOffer: function (currency, amount, duration, autoRenew, lendingRate, callback) { - var parameters = { - currency: currency, - amount: amount, - duration: duration, - autoRenew: autoRenew, - lendingRate: lendingRate - }; - - return this._private('createLoanOffer', parameters, callback); - }, - - cancelLoanOffer: function (orderNumber, callback) { - var parameters = { - orderNumber: orderNumber - }; - - return this._private('cancelLoanOffer', parameters, callback); - }, - - returnOpenLoanOffers: function (callback) { - return this._private('returnOpenLoanOffers', {}, callback); - }, - - returnActiveLoans: function (callback) { - return this._private('returnActiveLoans', {}, callback); - }, - - returnLendingHistory: function (start, end, limit, callback) { - var parameters = { - start: start, - end: end, - limit: limit - }; - - return this._private('returnLendingHistory', parameters, callback); - }, - - toggleAutoRenew: function (orderNumber, callback) { - return this._private('toggleAutoRenew', { orderNumber: orderNumber }, callback); - } - - }; - - // Backwards Compatibility - Poloniex.prototype.getTicker = Poloniex.prototype.returnTicker; - Poloniex.prototype.get24hVolume = Poloniex.prototype.return24hVolume; - Poloniex.prototype.getOrderBook = Poloniex.prototype.returnOrderBook; - Poloniex.prototype.getTradeHistory = Poloniex.prototype.returnChartData; - Poloniex.prototype.myBalances = Poloniex.prototype.returnBalances; - Poloniex.prototype.myOpenOrders = Poloniex.prototype.returnOpenOrders; - Poloniex.prototype.myTradeHistory = Poloniex.prototype.returnTradeHistory; - - return Poloniex; -})(); \ No newline at end of file diff --git a/Utilities.js b/Utilities.js deleted file mode 100644 index b70a5b5f2..000000000 --- a/Utilities.js +++ /dev/null @@ -1,81 +0,0 @@ - -exports.newUtilities = function newUtilities(BOT) { - - let bot = BOT; - const ROOT_DIR = '../'; - - const MODULE_NAME = "Utilities"; - - - const DEBUG_MODULE = require('./Debug Log'); - const logger = DEBUG_MODULE.newDebugLog(); - logger.fileName = MODULE_NAME; - logger.bot = bot; - - let utilities = { - pad: pad, - createFolderIfNeeded: createFolderIfNeeded, - calculatePresicion: calculatePresicion - }; - - return utilities; - - - function pad(str, max) { - str = str.toString(); - return str.length < max ? pad("0" + str, max) : str; - } - - function createFolderIfNeeded(path, azureFileStorage, callBackFunction) { - - let splittedPath = path.split("/"); - - let partialPath = ''; - let separator = ""; - - - let i = 0; - loop(); - - function loop() { - - partialPath = partialPath + separator + splittedPath[i]; - separator = "/"; - - i++; - - azureFileStorage.createFolder(partialPath, checkLoop); - - function checkLoop() { - - if (i === splittedPath.length) { - - callBackFunction(); - - } else { - - loop(); - - } - - - } - - } - - } - - - function calculatePresicion(number) { - - for (let i = -10; i <= 10; i++) { - if (number < Math.pow(10, i)) { - return Math.pow(10, i - 3); - } - } - } - - - - -} \ No newline at end of file diff --git a/this.bot.config.json b/this.bot.config.json new file mode 100644 index 000000000..31eb753b1 --- /dev/null +++ b/this.bot.config.json @@ -0,0 +1,34 @@ +{ + "bot": { + "name": "Bruce", + "type": "Indicator", + "version": "1.0.0", + "devTeam": "AA Masters" + }, + "processes": [ + { + "name": "One-Min-Daily-Candles-Volumes", + "description": "Produces two data-sets with candles and volumes for all markets at Poloniex.", + "startMode": { + "allMonths": { + "run": "false", + "minYear": "2014", + "maxYear": "2018" + }, + "oneMonth": { + "run": "true", + "year": "2018", + "month": "1" + }, + "noTime": { + "run": "false" + } + }, + "intervalLapse": 10000, + "intervalMaxLoops": -1 + } + ] +} + + +