From d29335489f0708d5022ddae71c0e5f2dce21b7de Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 4 Sep 2021 11:29:01 +0200 Subject: [PATCH] genereteUniqueId function moved to SA --- .gitignore | 1 + Desktop/DesktopApp.js | 2 +- .../SA/Utilities/MiscellaneousFunctions.js | 15 +++++++++++++++ .../Low-Frequency-Learning/LearningEpisode.js | 2 +- .../Low-Frequency-Trading/TradingEpisode.js | 2 +- .../Low-Frequency-Trading/TradingOrders.js | 2 +- .../Low-Frequency-Trading/TradingPosition.js | 2 +- .../Low-Frequency-Trading/TradingStrategy.js | 2 +- .../TS/Utilities/MiscellaneousFunctions.js | 8 -------- Projects/ProjectsSchema.json | 6 ++++++ .../Social-Trading/NT/Modules/ClientInterface.js | 14 +++++++++----- 11 files changed, 37 insertions(+), 19 deletions(-) create mode 100644 Projects/Foundations/SA/Utilities/MiscellaneousFunctions.js diff --git a/.gitignore b/.gitignore index 3d0bf0240..0ec8e557c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ Projects/Foundations/Icons/Thumbs.db *.exe node_modules launch.json +.idea diff --git a/Desktop/DesktopApp.js b/Desktop/DesktopApp.js index 91fc7a832..5dfbc3ea6 100644 --- a/Desktop/DesktopApp.js +++ b/Desktop/DesktopApp.js @@ -51,7 +51,7 @@ exports.newDesktopApp = function newDesktopApp() { Test Following Profiles. */ let eventMessage = { - eventId: i, + eventId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(), eventType: SA.projects.socialTrading.globals.eventTypes.FOLLOW_USER_PROFILE, emitterUserProfileId: DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID, targetUserProfileId: profile.userProfileId diff --git a/Projects/Foundations/SA/Utilities/MiscellaneousFunctions.js b/Projects/Foundations/SA/Utilities/MiscellaneousFunctions.js new file mode 100644 index 000000000..27c00cff2 --- /dev/null +++ b/Projects/Foundations/SA/Utilities/MiscellaneousFunctions.js @@ -0,0 +1,15 @@ +exports.newFoundationsUtilitiesMiscellaneousFunctions = function () { + + let thisObject = { + genereteUniqueId: genereteUniqueId + } + + return thisObject + + function genereteUniqueId() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8) + return v.toString(16) + }) + } +} \ No newline at end of file diff --git a/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningEpisode.js b/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningEpisode.js index 5ce13d58e..276a85fa2 100644 --- a/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningEpisode.js +++ b/Projects/Foundations/TS/Bot-Modules/Learning-Bot/Low-Frequency-Learning/LearningEpisode.js @@ -58,7 +58,7 @@ exports.newFoundationsBotModulesLearningEpisode = function (processIndex) { /* Recording the opening at the Learning Engine Data Structure */ learningEngine.learningCurrent.learningEpisode.status.value = 'Open' learningEngine.learningCurrent.learningEpisode.serialNumber.value = 1 - learningEngine.learningCurrent.learningEpisode.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() + learningEngine.learningCurrent.learningEpisode.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() learningEngine.learningCurrent.learningEpisode.beginRate.value = learningEngine.learningCurrent.learningEpisode.candle.close.value } diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js index 2570ab8c5..6c3b51cb2 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingEpisode.js @@ -66,7 +66,7 @@ exports.newFoundationsBotModulesTradingEpisode = function (processIndex) { /* Recording the opening at the Trading Engine Data Structure */ tradingEngine.tradingCurrent.tradingEpisode.status.value = 'Open' tradingEngine.tradingCurrent.tradingEpisode.serialNumber.value = 1 - tradingEngine.tradingCurrent.tradingEpisode.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() + tradingEngine.tradingCurrent.tradingEpisode.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() tradingEngine.tradingCurrent.tradingEpisode.beginRate.value = tradingEngine.tradingCurrent.tradingEpisode.candle.close.value } diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOrders.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOrders.js index fe9107dba..91d1958d2 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOrders.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingOrders.js @@ -361,7 +361,7 @@ exports.newFoundationsBotModulesTradingOrders = function (processIndex) { /* Create Order Procedure */ tradingEngineOrder.status.value = 'Open' - tradingEngineOrder.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() + tradingEngineOrder.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() tradingEngineOrder.begin.value = tradingEngine.tradingCurrent.tradingEpisode.cycle.begin.value tradingEngineOrder.end.value = tradingEngine.tradingCurrent.tradingEpisode.cycle.end.value tradingEngineOrder.serialNumber.value = tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeCounters.orders.value diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js index 61b3ddb06..f2de2313c 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingPosition.js @@ -58,7 +58,7 @@ exports.newFoundationsBotModulesTradingPosition = function (processIndex) { /* Recording the opening at the Trading Engine Data Structure */ tradingEngine.tradingCurrent.position.status.value = 'Open' tradingEngine.tradingCurrent.position.serialNumber.value = tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeCounters.positions.value + 1 - tradingEngine.tradingCurrent.position.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() + tradingEngine.tradingCurrent.position.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() tradingEngine.tradingCurrent.position.beginRate.value = tradingEngine.tradingCurrent.tradingEpisode.candle.close.value tradingEngine.tradingCurrent.position.positionBaseAsset.beginBalance.value = tradingEngine.tradingCurrent.tradingEpisode.episodeBaseAsset.balance.value tradingEngine.tradingCurrent.position.positionQuotedAsset.beginBalance.value = tradingEngine.tradingCurrent.tradingEpisode.episodeQuotedAsset.balance.value diff --git a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStrategy.js b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStrategy.js index da4f00516..f676de4d7 100644 --- a/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStrategy.js +++ b/Projects/Foundations/TS/Bot-Modules/Trading-Bot/Low-Frequency-Trading/TradingStrategy.js @@ -44,7 +44,7 @@ exports.newFoundationsBotModulesTradingStrategy = function (processIndex) { /* Recording the opening at the Trading Engine Data Structure */ tradingEngine.tradingCurrent.strategy.status.value = 'Open' tradingEngine.tradingCurrent.strategy.serialNumber.value = tradingEngine.tradingCurrent.tradingEpisode.tradingEpisodeCounters.strategies.value - tradingEngine.tradingCurrent.strategy.identifier.value = TS.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() + tradingEngine.tradingCurrent.strategy.identifier.value = SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId() tradingEngine.tradingCurrent.strategy.beginRate.value = tradingEngine.tradingCurrent.tradingEpisode.candle.min.value tradingEngine.tradingCurrent.strategy.index.value = index diff --git a/Projects/Foundations/TS/Utilities/MiscellaneousFunctions.js b/Projects/Foundations/TS/Utilities/MiscellaneousFunctions.js index 16aae45ce..502378e7d 100644 --- a/Projects/Foundations/TS/Utilities/MiscellaneousFunctions.js +++ b/Projects/Foundations/TS/Utilities/MiscellaneousFunctions.js @@ -1,7 +1,6 @@ exports.newFoundationsUtilitiesMiscellaneousFunctions = function () { let thisObject = { - genereteUniqueId: genereteUniqueId, truncateToThisPrecision: truncateToThisPrecision, pad: pad, asyncGetDatasetFile: asyncGetDatasetFile, @@ -10,13 +9,6 @@ exports.newFoundationsUtilitiesMiscellaneousFunctions = function () { return thisObject - function genereteUniqueId() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8) - return v.toString(16) - }) - } - function truncateToThisPrecision(floatNumber, precision) { return parseFloat(floatNumber.toFixed(precision)) } diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index c9d40726a..f60a3f0f5 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -894,6 +894,12 @@ "propertyName": "plugins", "functionName": "newFoundationsUtilitiesPlugins", "fileName": "Plugins.js" + }, + { + "name": "Miscellaneous Functions", + "propertyName": "miscellaneousFunctions", + "functionName": "newFoundationsUtilitiesMiscellaneousFunctions", + "fileName": "MiscellaneousFunctions.js" } ] }, diff --git a/Projects/Social-Trading/NT/Modules/ClientInterface.js b/Projects/Social-Trading/NT/Modules/ClientInterface.js index b74c0b675..16a1f1978 100644 --- a/Projects/Social-Trading/NT/Modules/ClientInterface.js +++ b/Projects/Social-Trading/NT/Modules/ClientInterface.js @@ -123,7 +123,7 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule let response = { result: 'Ok', - message: 'Client Interface Event Processed.' + message: 'Client Interface Event Processed.' } return response @@ -132,9 +132,11 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule Any exception that happens while trying to change the state of the Social Graph, will be returned to the caller without doing anything else here. */ + let errorMessage = err.message + if (errorMessage === undefined) { errorMessage = err } let response = { result: 'Error', - message: 'Client Interface ' + err.message + message: 'Client Interface ' + errorMessage } return response } @@ -191,21 +193,23 @@ exports.newSocialTradingModulesClientInterface = function newSocialTradingModule try { let query = NT.projects.socialTrading.modules.query.newSocialTradingModulesQuery() query.initialize(queryReceived) - + let response = { result: 'Ok', message: 'Client Interface Query Processed.', data: query.execute() } return response - + } catch (err) { /* Any exception that happens while trying to execute the query. */ + let errorMessage = err.message + if (errorMessage === undefined) { errorMessage = err } let response = { result: 'Error', - message: err.message + message: 'Client Interface ' + errorMessage } return response }