From b7f36f8d4c6d910300771434e5232b58f7af6cdf Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 27 May 2021 21:03:08 +0200 Subject: [PATCH 1/3] New Troubleshooting Page --- ...oting-018-problems-with-computer-time.json | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Projects/Superalgos/Schemas/Docs-Topics/troubleshooting-018-problems-with-computer-time.json diff --git a/Projects/Superalgos/Schemas/Docs-Topics/troubleshooting-018-problems-with-computer-time.json b/Projects/Superalgos/Schemas/Docs-Topics/troubleshooting-018-problems-with-computer-time.json new file mode 100644 index 000000000..5edd8c681 --- /dev/null +++ b/Projects/Superalgos/Schemas/Docs-Topics/troubleshooting-018-problems-with-computer-time.json @@ -0,0 +1,52 @@ +{ + "topic": "Troubleshooting", + "pageNumber": "18", + "type": "Problems With Computer Time", + "definition": { + "text": "Some exchanges force the computer that is running your bot to be highly syncronized with thier servers, and to achieve that you need that machine's time to keep itself syncronized with an Internet Time Server.", + "updated": 1622140103759 + }, + "paragraphs": [ + { + "style": "Title", + "text": "How to identify this problem?", + "updated": 1622140152661 + }, + { + "style": "Text", + "text": "If you receive an error like this, you are having this type of problem:" + }, + { + "style": "Javascript", + "text": "['2021-05-27T15:24:15.339Z',246,'Exchange API','[ERROR] createOrder -> \nError = binance {\"code\":-1021,\n\"msg\":\"Timestamp for this request is outside of the recvWindow.\"}'] \n@ Masters-Low-Frequency-Trading", + "updated": 1622140198558 + }, + { + "style": "Title", + "text": "How to solve this problem?", + "updated": 1622140378812 + }, + { + "style": "Text", + "text": "You can use the server time.nist.gov that has proven to work in this situation. Look for the place at your OS where you can change the Internet Time Settings and use that server there." + }, + { + "style": "Subtitle", + "text": "Docker Users" + }, + { + "style": "Text", + "text": "Sometimes Docker might not be in sync even though the underlaying OS it is. To fix this, you can run this command, which will force Docker to restart and wsl to pickup the correct time from the OS.", + "updated": 1622140496709 + }, + { + "style": "Javascript", + "text": "wsl --shutdown", + "updated": 1622140514881 + }, + { + "style": "Text", + "text": "" + } + ] +} \ No newline at end of file From d24604ec247c19d34c2e62d650a5f9444e5d2e91 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 28 May 2021 02:05:22 +0200 Subject: [PATCH 2/3] API Data Fetcher feature parameters with default values at the API Map --- .../Docs-Nodes/api-query-parameter.json | 4 +- .../API-Data-Fetcher-Bot/FetchingProcess.js | 114 +++++++++++++----- 2 files changed, 85 insertions(+), 33 deletions(-) diff --git a/Projects/Superalgos/Schemas/Docs-Nodes/api-query-parameter.json b/Projects/Superalgos/Schemas/Docs-Nodes/api-query-parameter.json index c80fb3b09..ac68b8246 100644 --- a/Projects/Superalgos/Schemas/Docs-Nodes/api-query-parameter.json +++ b/Projects/Superalgos/Schemas/Docs-Nodes/api-query-parameter.json @@ -16,8 +16,8 @@ }, { "style": "List", - "text": "value: It is the value to be used at this parameter. The API Map can define the value, that would be considered a default value. The same parameter defined at the Data Mine will have the actual value to be used replacing the default.", - "updated": 1621022463369 + "text": "value: It is the value to be used at this parameter. The API Map can define the value, that would be considered a default value. The same parameter defined at the Data Mine will have the actual value to be used replacing the default. If you are defining a API Map to be shared as a Plugin, you can avoid setting this property at the API Map level, and let the users set it at their Data Mine when they use your API Map. For completness, this parameter should be included at the the API Map even if the value property is not there.", + "updated": 1622160191941 } ] } \ No newline at end of file diff --git a/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js b/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js index b13a52c9d..8bd901f01 100644 --- a/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js @@ -305,23 +305,49 @@ exports.newSuperalgosBotModulesFetchingProcess = function (processIndex) { /* Parameters to the query of the API are all optional. Here we will see if we need to place the API call with Parameters... + + The Parameters defined at the API Map will be the default values that + can be overwritten by the ones at the Data Mine. + + We will create parametersMap to handle this. + */ + let parametersMap = new Map() + if (endpointNode.apiQueryParameters !== undefined) { + for (let i = 0; i < endpointNode.apiQueryParameters.apiQueryParameters.length; i++) { + apiQueryParameter = endpointNode.apiQueryParameters.apiQueryParameters[i] + addParameterToMap(apiQueryParameter) + } + } + /* + The parameters defined at the Data Mine will overwrite whatever is at the API Map */ - let separator = "" if (productDefinition.apiQueryParameters !== undefined) { - queryString = '?' for (j = 0; j < productDefinition.apiQueryParameters.apiQueryParameters.length; j++) { let apiQueryParameter = productDefinition.apiQueryParameters.apiQueryParameters[j] + addParameterToMap(apiQueryParameter) + } + } - /* - There is a special parameter which has a flag to indicate is a Page Number. - This will be treated differently since we will need to iterate to get each possible page. - The page number will no be added here to the query string. - */ - if (apiQueryParameter.config.isPageNumber === true) { - pageNumberParameter = apiQueryParameter - } else { - queryString = queryString + separator + apiQueryParameter.config.codeName + '=' + apiQueryParameter.config.value - separator = "&" + let separator = "" + queryString = '?' + parametersMap.forEach(addParameterToQueryString) + + function addParameterToQueryString(value, key, map) { + queryString = queryString + separator + key + '=' + value + separator = "&" + } + + function addParameterToMap(apiQueryParameter) { + /* + There is a special parameter which has a flag to indicate is a Page Number. + This will be treated differently since we will need to iterate to get each possible page. + The page number will no be added here to the query string. + */ + if (apiQueryParameter.config.isPageNumber === true) { + pageNumberParameter = apiQueryParameter + } else { + if (apiQueryParameter.config.codeName !== undefined && apiQueryParameter.config.value !== undefined) { + parametersMap.set(apiQueryParameter.config.codeName, apiQueryParameter.config.value) } } } @@ -331,29 +357,55 @@ exports.newSuperalgosBotModulesFetchingProcess = function (processIndex) { /* Parameters to the path of the API are all optional. Here we will see if we need to place the API call with Parameters... - */ - let separator = "" - if (productDefinition.apiPathParameters !== undefined) { - pathString = '/' - for (let j = 0; j < productDefinition.apiPathParameters.apiPathParameters.length; j++) { - let apiPathParameter = productDefinition.apiPathParameters.apiPathParameters[j] + The Parameters defined at the API Map will be the default values that + can be overwritten by the ones at the Data Mine. - let parameterValue = apiPathParameter.config.codeName // This is the default value - if (apiPathParameter.config.replaceBy !== undefined) { - switch (apiPathParameter.config.replaceBy) { - case '@BaseAsset': { - parameterValue = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName - break - } - case '@QuotedAsset': { - parameterValue = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName - break - } + We will create parametersMap to handle this. + */ + let parametersMap = new Map() + if (endpointNode.apiPathParameters !== undefined) { + for (let i = 0; i < endpointNode.apiPathParameters.apiPathParameters.length; i++) { + apiPathParameter = endpointNode.apiPathParameters.apiPathParameters[i] + addParameterToMap(apiPathParameter) + } + } + /* + The parameters defined at the Data Mine will overwrite whatever is at the API Map + */ + if (productDefinition.apiPathParameters !== undefined) { + for (j = 0; j < productDefinition.apiPathParameters.apiPathParameters.length; j++) { + let apiPathParameter = productDefinition.apiPathParameters.apiPathParameters[j] + addParameterToMap(apiPathParameter) + } + } + + function addParameterToMap(apiPathParameter) { + if (apiPathParameter.config.codeName !== undefined) { + parametersMap.set(apiPathParameter.config.codeName, apiPathParameter) + } + } + + let separator = "" + pathString = '/' + parametersMap.forEach(addParameterToPath) + + function addParameterToPath(value, key, map) { + let apiPathParameter = value + let parameterValue = key // This is the default value + if (apiPathParameter.config.replaceBy !== undefined) { + switch (apiPathParameter.config.replaceBy) { + case '@BaseAsset': { + parameterValue = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + break + } + case '@QuotedAsset': { + parameterValue = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + break } } - pathString = pathString + separator + parameterValue - separator = "/" } + pathString = pathString + separator + parameterValue + separator = "/" } } From dfff4b387dfe7d9c1ca15ffd5d251e22d1a39db3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 28 May 2021 02:29:46 +0200 Subject: [PATCH 3/3] API Data Fetcher DeepScan Bugs Fixed --- .../Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js b/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js index 8bd901f01..8f5cc25b3 100644 --- a/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js +++ b/Projects/Superalgos/TS/Bot-Modules/API-Data-Fetcher-Bot/FetchingProcess.js @@ -314,7 +314,7 @@ exports.newSuperalgosBotModulesFetchingProcess = function (processIndex) { let parametersMap = new Map() if (endpointNode.apiQueryParameters !== undefined) { for (let i = 0; i < endpointNode.apiQueryParameters.apiQueryParameters.length; i++) { - apiQueryParameter = endpointNode.apiQueryParameters.apiQueryParameters[i] + let apiQueryParameter = endpointNode.apiQueryParameters.apiQueryParameters[i] addParameterToMap(apiQueryParameter) } } @@ -322,7 +322,7 @@ exports.newSuperalgosBotModulesFetchingProcess = function (processIndex) { The parameters defined at the Data Mine will overwrite whatever is at the API Map */ if (productDefinition.apiQueryParameters !== undefined) { - for (j = 0; j < productDefinition.apiQueryParameters.apiQueryParameters.length; j++) { + for (let j = 0; j < productDefinition.apiQueryParameters.apiQueryParameters.length; j++) { let apiQueryParameter = productDefinition.apiQueryParameters.apiQueryParameters[j] addParameterToMap(apiQueryParameter) } @@ -365,7 +365,7 @@ exports.newSuperalgosBotModulesFetchingProcess = function (processIndex) { let parametersMap = new Map() if (endpointNode.apiPathParameters !== undefined) { for (let i = 0; i < endpointNode.apiPathParameters.apiPathParameters.length; i++) { - apiPathParameter = endpointNode.apiPathParameters.apiPathParameters[i] + let apiPathParameter = endpointNode.apiPathParameters.apiPathParameters[i] addParameterToMap(apiPathParameter) } } @@ -373,7 +373,7 @@ exports.newSuperalgosBotModulesFetchingProcess = function (processIndex) { The parameters defined at the Data Mine will overwrite whatever is at the API Map */ if (productDefinition.apiPathParameters !== undefined) { - for (j = 0; j < productDefinition.apiPathParameters.apiPathParameters.length; j++) { + for (let j = 0; j < productDefinition.apiPathParameters.apiPathParameters.length; j++) { let apiPathParameter = productDefinition.apiPathParameters.apiPathParameters[j] addParameterToMap(apiPathParameter) }