diff --git a/.vs/AACharly/v15/.suo b/.vs/AACharly/v15/.suo index 93e438b64..a1a83b56e 100644 Binary files a/.vs/AACharly/v15/.suo and b/.vs/AACharly/v15/.suo differ diff --git a/AACharly.njsproj b/AACharly.njsproj index 16da68313..6d6b72fc1 100644 --- a/AACharly.njsproj +++ b/AACharly.njsproj @@ -6,7 +6,8 @@ {ae0a3fe2-7021-4cc2-9922-a887ca5cdd7c} ShowAllFiles - Poloniex-Hole-Fixing\run.js + + c:\users\luis\source\repos\AACharly\Poloniex-Hole-Fixing . {3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD} @@ -17,21 +18,10 @@ - - - - - - - - - - - - + diff --git a/AACharly.sln b/AACharly.sln index 9ebd7e1df..48a43c66f 100644 --- a/AACharly.sln +++ b/AACharly.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}") = "AACharly", "AACharly.njsproj", "{AE0A3FE2-7021-4CC2-9922-A887CA5CDD7C}" 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/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/Poloniex-Historic-Trades/Interval.js b/Poloniex-Historic-Trades/Interval.js index f3b236951..086fb1aab 100644 --- a/Poloniex-Historic-Trades/Interval.js +++ b/Poloniex-Historic-Trades/Interval.js @@ -1,7 +1,7 @@ -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 = '../'; + const ROOT_DIR = './'; const GMT_SECONDS = ':00.000 GMT+0000'; const GMT_MILI_SECONDS = '.000 GMT+0000'; @@ -16,11 +16,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 POLONIEX_CLIENT_MODULE = require(ROOT_DIR + 'Poloniex API Client'); - - const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log'); const logger = DEBUG_MODULE.newDebugLog(); logger.fileName = MODULE_NAME; logger.bot = bot; @@ -32,10 +27,8 @@ let markets; - const AZURE_FILE_STORAGE = require(ROOT_DIR + 'Azure File Storage'); let azureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); - const UTILITIES = require(ROOT_DIR + 'Utilities'); let utilities = UTILITIES.newUtilities(bot); let year; diff --git a/Poloniex-Historic-Trades/Poloniex Historic Trades.js b/Poloniex-Historic-Trades/Poloniex Historic Trades.js deleted file mode 100644 index af8431a81..000000000 --- a/Poloniex-Historic-Trades/Poloniex Historic Trades.js +++ /dev/null @@ -1,169 +0,0 @@ -exports.newPloniexHistoricTrades = function newPloniexHistoricTrades(BOT) { - - let bot = BOT; - const ROOT_DIR = '../'; - - const INTERVAL_LAPSE = 24 * 60 * 60 * 1000; - - const MODULE_NAME = "Poloniex Exchange Historic Trades"; - 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. - - poloniexHistoricTrades = { - 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 poloniexHistoricTrades; - - 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); - - startNewInterval(); // 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/Poloniex-Historic-Trades/run.js b/Poloniex-Historic-Trades/run.js deleted file mode 100644 index b04555958..000000000 --- a/Poloniex-Historic-Trades/run.js +++ /dev/null @@ -1,97 +0,0 @@ - -let bot = { - name: "Charly", - process: "Historic-Trades", - type: "Connectivity", - version: "1.0.0", - devTeam: "AA Masters" -}; - -const ROOT_DIR = '../'; - -const MODULE_NAME = "run"; - -const START_POLONIEX_HISTORIC_TRADES = true; -const START_POLONIEX_HISTORIC_TRADES_AT_ONE_MONTH = false; - -const POLONIEX_HISTORIC_TRADES_MODULE = require('./Poloniex Historic Trades'); - -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_POLONIEX_HISTORIC_TRADES === true) { - - for (let year = 2018; year > 2014; year--) { - - for (let month = 12; month > 0; month--) { - - let timeDelay = Math.random() * 100 * 1000; // We need a delay so as not to get banned from the exchange for requesting to many things at the same time. - - setTimeout(startProcess, timeDelay); - - function startProcess() { - - const newPloniexHistoricTrades = POLONIEX_HISTORIC_TRADES_MODULE.newPloniexHistoricTrades(bot); - - newPloniexHistoricTrades.initialize(year, month, onInitializeReady); - - function onInitializeReady() { - - newPloniexHistoricTrades.start(); - - } - - } - - } - - } - - } - - - if (START_POLONIEX_HISTORIC_TRADES_AT_ONE_MONTH === true) { - - startProcess(); - - function startProcess() { - - const newPloniexHistoricTrades = POLONIEX_HISTORIC_TRADES_MODULE.newPloniexHistoricTrades(bot); - - let month = 12; - let year = 2017; - - newPloniexHistoricTrades.initialize(year, month, onInitializeReady); - - function onInitializeReady() { - - newPloniexHistoricTrades.start(); - - } - } - } - - -} catch (err) { - console.log(err.message); - logger.write(err.message); -} - diff --git a/Poloniex-Hole-Fixing/Interval.js b/Poloniex-Hole-Fixing/Interval.js index 744a74635..5a2153792 100644 --- a/Poloniex-Hole-Fixing/Interval.js +++ b/Poloniex-Hole-Fixing/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 = '../'; @@ -16,11 +16,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 POLONIEX_CLIENT_MODULE = require(ROOT_DIR + 'Poloniex API Client'); - - const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log'); const logger = DEBUG_MODULE.newDebugLog(); logger.fileName = MODULE_NAME; logger.bot = bot; @@ -32,10 +27,8 @@ let markets; - const AZURE_FILE_STORAGE = require(ROOT_DIR + 'Azure File Storage'); let azureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); - const UTILITIES = require(ROOT_DIR + 'Utilities'); let utilities = UTILITIES.newUtilities(bot); let year; diff --git a/Poloniex-Hole-Fixing/Poloniex Hole Fixing.js b/Poloniex-Hole-Fixing/Poloniex Hole Fixing.js deleted file mode 100644 index a9d5210e2..000000000 --- a/Poloniex-Hole-Fixing/Poloniex Hole Fixing.js +++ /dev/null @@ -1,169 +0,0 @@ -exports.newPloniexHoleFixing = function newPloniexHoleFixing(BOT) { - - let bot = BOT; - const ROOT_DIR = '../'; - - const INTERVAL_LAPSE = 60 * 1000; - - const MODULE_NAME = "Poloniex Exchange Hole Fixing"; - 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/Poloniex-Hole-Fixing/run.js b/Poloniex-Hole-Fixing/run.js deleted file mode 100644 index 1d25ced2e..000000000 --- a/Poloniex-Hole-Fixing/run.js +++ /dev/null @@ -1,97 +0,0 @@ - -let bot = { - name: "Charly", - process: "Hole-Fixing", - type: "Connectivity", - version: "1.0.0", - devTeam: "AA Masters" -}; - -const ROOT_DIR = '../'; - -const MODULE_NAME = "run"; - -const START_POLONIEX_HOLE_FIXING = true; -const START_POLONIEX_HOLE_FIXING_AT_ONE_MONTH = false; - -const POLONIEX_HOLE_FIXING_MODULE = require('./Poloniex Hole Fixing'); - -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_POLONIEX_HOLE_FIXING === true) { - - for (let year = 2018; year > 2014; year--) { - - for (let month = 12; month > 0; month--) { - - let timeDelay = Math.random() * 100 * 1000; // We need a delay so as not to get banned from the exchange for requesting to many things at the same time. - - setTimeout(startProcess, timeDelay); - - function startProcess() { - - const newPloniexHoleFixing = POLONIEX_HOLE_FIXING_MODULE.newPloniexHoleFixing(bot); - - newPloniexHoleFixing.initialize(year, month, onInitializeReady); - - function onInitializeReady() { - - newPloniexHoleFixing.start(); - - } - - } - - } - - } - - } - - - if (START_POLONIEX_HOLE_FIXING_AT_ONE_MONTH === true) { - - startProcess(); - - function startProcess() { - - const newPloniexHoleFixing = POLONIEX_HOLE_FIXING_MODULE.newPloniexHoleFixing(bot); - - let month = 2; - let year = 2015; - - newPloniexHoleFixing.initialize(year, month, onInitializeReady); - - function onInitializeReady() { - - newPloniexHoleFixing.start(); - - } - } - } - - -} catch (err) { - console.log(err.message); - logger.write(err.message); -} - diff --git a/Poloniex-Live-Trades/Interval.js b/Poloniex-Live-Trades/Interval.js index 775727b85..13af05eb9 100644 --- a/Poloniex-Live-Trades/Interval.js +++ b/Poloniex-Live-Trades/Interval.js @@ -1,7 +1,7 @@ -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 = '../'; + const ROOT_DIR = './'; const GMT_SECONDS = ':00.000 GMT+0000'; const GMT_MILI_SECONDS = '.000 GMT+0000'; @@ -17,11 +17,6 @@ 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 MARKETS_MODULE = require(ROOT_DIR + 'Markets'); - - const POLONIEX_CLIENT_MODULE = require(ROOT_DIR + 'Poloniex API Client'); - - const DEBUG_MODULE = require(ROOT_DIR + 'Debug Log'); const logger = DEBUG_MODULE.newDebugLog(); logger.fileName = MODULE_NAME; logger.bot = bot; @@ -33,15 +28,13 @@ let markets; - const AZURE_FILE_STORAGE = require(ROOT_DIR + 'Azure File Storage'); let azureFileStorage = AZURE_FILE_STORAGE.newAzureFileStorage(bot); - const UTILITIES = require(ROOT_DIR + 'Utilities'); let utilities = UTILITIES.newUtilities(bot); return interval; - function initialize(callBackFunction) { + function initialize(pYear, pMonth, callBackFunction) { // Year and Month ignored at this process. try { diff --git a/Poloniex-Live-Trades/Poloniex Live Trades.js b/Poloniex-Live-Trades/Poloniex Live Trades.js deleted file mode 100644 index b4dc974c2..000000000 --- a/Poloniex-Live-Trades/Poloniex Live Trades.js +++ /dev/null @@ -1,106 +0,0 @@ -exports.newPloniexLiveTrades = function newPloniexLiveTrades(BOT) { - - let bot = BOT; - const ROOT_DIR = '../'; - - const INTERVAL_LAPSE = 60 * 1000; - - const MODULE_NAME = "Poloniex Exchange Live Trades"; - 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; - - poloniexLiveTrades = { - initialize: initialize, - start: start - }; - - const SHUTDOWN_EVENT = require(ROOT_DIR + 'Azure Web Job Shutdown'); - let shutdownEvent = SHUTDOWN_EVENT.newShutdownEvent(bot); - - return poloniexLiveTrades; - - function initialize(callBackFunction) { - - try { - - const logText = "[INFO] initialize - Entering function 'initialize' "; - 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 { - - let intervalId = setInterval(startNewInterval, INTERVAL_LAPSE); - - startNewInterval(); // First, inmadiate run. - - - - function startNewInterval() { - - try { - - if (LOG_INFO === true) { - 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(onReadyToStart); - - function onReadyToStart() { - - fileProcessingInterval.start(); - - } - - } - 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); - } - } - - } - catch (err) { - const logText = "[ERROR] 'Start' - ERROR : " + err.message; - logger.write(logText); - } - } -}; - - - diff --git a/Poloniex-Live-Trades/run.js b/Poloniex-Live-Trades/run.js deleted file mode 100644 index 2782c137d..000000000 --- a/Poloniex-Live-Trades/run.js +++ /dev/null @@ -1,57 +0,0 @@ - -let bot = { - name: "Charly", - process: "Live-Trades", - type: "Connectivity", - version: "1.0.0", - devTeam: "AA Masters" -}; - -const ROOT_DIR = '../'; - -const MODULE_NAME = "run"; - -const START_POLONIEX_LIVE_TRADES = true; - -const POLONIEX_LIVE_TRADES_MODULE = require('./Poloniex Live Trades'); - -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_POLONIEX_LIVE_TRADES === true) { - - const newPloniexLiveTrades = POLONIEX_LIVE_TRADES_MODULE.newPloniexLiveTrades(bot); - - newPloniexLiveTrades.initialize(onInitializeReady); - - function onInitializeReady() { - - newPloniexLiveTrades.start(); - - } - - } - -} catch (err) { - console.log(err.message); - logger.write(err.message); -} - 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/logs/Dummy File.txt b/logs/Dummy File.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/this.bot.config.json b/this.bot.config.json new file mode 100644 index 000000000..6f955d748 --- /dev/null +++ b/this.bot.config.json @@ -0,0 +1,76 @@ +{ + "bot": { + "name": "Charly", + "type": "Extracting", + "version": "1.0.0", + "devTeam": "AA Masters" + }, + "processes": [ + { + "name": "Poloniex-Live-Trades", + "description": "Retrieves the trades done at the current and the previous minute and saves them at the storage account.", + "startMode": { + "allMonths": { + "run": "false", + "minYear": "", + "maxYear": "" + }, + "oneMonth": { + "run": "false", + "year": "", + "month": "" + }, + "noTime": { + "run": "true" + } + }, + "intervalLapse": 60000, + "intervalMaxLoops": 0 + }, + { + "name": "Poloniex-Historic-Trades", + "description": "Retrieves and saves the historical trades in batches going backwards from the current time until reaching the begining of the market.", + "startMode": { + "allMonths": { + "run": "true", + "minYear": "2014", + "maxYear": "2018" + }, + "oneMonth": { + "run": "false", + "year": "", + "month": "" + }, + "noTime": { + "run": "false" + } + }, + "intervalLapse": 30000, + "intervalMaxLoops": -1 + }, + { + "name": "Poloniex-Hole-Fixing", + "description": "Scans the trades saved by the Live Trades and Historic Trades processes searching for missing records. Once a hole is found on the data set, it patches it by retrieving the missing records from the exchange.", + "startMode": { + "allMonths": { + "run": "true", + "minYear": "2014", + "maxYear": "2018" + }, + "oneMonth": { + "run": "false", + "year": "", + "month": "" + }, + "noTime": { + "run": "false" + } + }, + "intervalLapse": 60000, + "intervalMaxLoops": -1 + } + ] +} + + +