Merge pull request #447 from Luis-Fernando-Molina/develop

Contribution: Trading Session Errors Topic
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-01-22 18:19:45 +01:00
commit 1fa826329a
14 files changed
+356 -28

No files matched your search

+1 -1
View File
@@ -563,7 +563,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
}
function cleanFileName(fileName) {
for (let i = 0; i < 10; i++) {
for (let i = 0; i < 100; i++) {
fileName = fileName
.replace(' ', '-')
.replace('--', '-')
@@ -0,0 +1,14 @@
{
"type": "Node JS Javsacript",
"definition": {
"text": "A Task in Superalgos runs in Node JS, which means that the Conditions and Formulas you write at your Trading System must comply with Javascript for Node JS syntax. ",
"updated": 1611323749488
},
"paragraphs": [
{
"style": "Text",
"text": "The same is true for properties values in configs. They need to be valid data types of Javascript for Node JS.",
"updated": 1611323797820
}
]
}
@@ -0,0 +1,16 @@
{
"topic": "TS Trading Session Errors",
"pageNumber": "1",
"type": "TS Trading Session Error - Parameters Node Missing",
"definition": {
"text": "The Backtesting Session, Live Trading Session, Paper Trading Session and Forward Testing Session nodes are expected to have a child of type Trading Parameters, and in this case it could not be found.",
"updated": 1611322334493
},
"paragraphs": [
{
"style": "Success",
"text": "To fix this, add a Trading Parameters child and try again.",
"updated": 1611322031139
}
]
}
@@ -0,0 +1,34 @@
{
"topic": "TS Trading Session Errors",
"pageNumber": "2",
"type": "TS Trading Session Error - Invalid Initial Datetime Property Value",
"definition": {
"text": "The initialDatetime property configured at the Time Range node is not recongnized as a valid Javascript Datetime.",
"updated": 1611322806779
},
"paragraphs": [
{
"style": "Text",
"text": "The validation of sessionParameters.timeRange.config.initialDatetime did not pass, and therefore the Trading Session can not run.",
"updated": 1611322904690
},
{
"style": "Success",
"text": "Check Node JS Javsacript docs to learn how to correctly express a datetime value.",
"updated": 1611323830743
},
{
"style": "Title",
"text": "Current Value"
},
{
"style": "Text",
"text": "The property at the moment has the following value. Note that a value will be shown below only if you received this error, not when you navigate to this error page via other means.",
"updated": 1611335177840
},
{
"style": "Placeholder",
"text": "currentValue"
}
]
}
@@ -0,0 +1,38 @@
{
"topic": "TS Trading Session Errors",
"pageNumber": "3",
"type": "TS Trading Session Error - Invalid Final Datetime Property Value",
"definition": {
"text": "The finalDatetime property configured at the Time Range node is not recongnized as a valid Javascript Datetime.",
"updated": 1611323471271
},
"paragraphs": [
{
"style": "Text",
"text": "The validation of sessionParameters.timeRange.config.finalDatetime did not pass, and therefore the Trading Session can not run.",
"updated": 1611323500247
},
{
"style": "Success",
"text": "Check Node JS Javsacript docs to learn how to correctly express a datetime value.",
"updated": 1611323848427
},
{
"style": "Title",
"text": "Current Value"
},
{
"style": "Text",
"text": "The property at the moment has the following value. Note that a value will be shown below only if you received this error, not when you navigate to this error page via other means.",
"updated": 1611335188490
},
{
"style": "Placeholder",
"text": "currentValue"
},
{
"style": "Text",
"text": ""
}
]
}
@@ -0,0 +1,16 @@
{
"topic": "TS Trading Session Errors",
"pageNumber": "4",
"type": "TS Trading Session Error - Time Frame Node Missing",
"definition": {
"text": "A Time Frame Node is expected and needed in order to run a Trading Session.",
"updated": 1611331109699
},
"paragraphs": [
{
"style": "Success",
"text": "Add a Time Frame Node at the Trading Parameters Node where this error poped up, check it's config and try running the Trading Session again.",
"updated": 1611331091819
}
]
}
@@ -0,0 +1,25 @@
{
"topic": "TS Trading Session Errors",
"pageNumber": "5",
"type": "TS Trading Session Error - Label Property Missing",
"definition": {
"text": "A property called label is expeceted at the Time Frame Node config, but it is missing.",
"updated": 1611332389501
},
"paragraphs": [
{
"style": "Success",
"text": "Add the label property at the Time Frame Node and try running the Trading Session again.",
"updated": 1611332549238
},
{
"style": "Title",
"text": "Example",
"updated": 1611332609003
},
{
"style": "Json",
"text": "01-min or 01-hs"
}
]
}
@@ -0,0 +1,38 @@
{
"topic": "TS Trading Session Errors",
"pageNumber": "6",
"type": "TS Trading Session Error - Invalid Label Property Value",
"definition": {
"text": "This property expects you to define the Time Frame in which the Trading Session is going to run. The current value assigned to the property is not recognized as a valid value.",
"updated": 1611333049475
},
"paragraphs": [
{
"style": "Success",
"text": "The value you currently have is invalid. You need to change it and run the Trading Session again.",
"updated": 1611333073771
},
{
"style": "Title",
"text": "Current Value"
},
{
"style": "Text",
"text": "The property at the moment has the following value. Note that a value will be shown below only if you received this error, not when you navigate to this error page via other means.",
"updated": 1611335162269
},
{
"style": "Placeholder",
"text": "currentValue"
},
{
"style": "Title",
"text": "Possible Values"
},
{
"style": "Json",
"text": " \"24-hs\",\n \"12-hs\",\n \"08-hs\",\n \"06-hs\",\n \"04-hs\",\n \"03-hs\",\n \"02-hs\",\n \"01-hs\"\n \"45-min\",\n \"40-min\",\n \"30-min\",\n \"20-min\",\n \"15-min\",\n \"10-min\",\n \"05-min\",\n \"04-min\",\n \"03-min\",\n \"02-min\",\n \"01-min\"",
"updated": 1611332924603
}
]
}
@@ -0,0 +1,16 @@
{
"topic": "TS Trading Session Errors",
"pageNumber": "7",
"type": "TS Trading Session Error - Session Base Asset Node Missing",
"definition": {
"text": "A Session Base Asset Node is expected and needed in order to run a Trading Session.",
"updated": 1611331205570
},
"paragraphs": [
{
"style": "Success",
"text": "Add a Session Base Asset Node at the Trading Parameters Node where this error poped up, check it's config and try running the Trading Session again.",
"updated": 1611331221697
}
]
}
@@ -0,0 +1,16 @@
{
"topic": "TS Trading Session Errors",
"pageNumber": "8",
"type": "TS Trading Session Error - Session Quoted Asset Node Missing",
"definition": {
"text": "A Session Quoted Asset Node is expected and needed in order to run a Trading Session.",
"updated": 1611331335567
},
"paragraphs": [
{
"style": "Success",
"text": "Add a Session Quoted Asset Node at the Trading Parameters Node where this error poped up, check it's config and try running the Trading Session again.",
"updated": 1611331377674
}
]
}
@@ -0,0 +1,16 @@
{
"topic": "TS Trading Session Errors",
"pageNumber": "9",
"type": "TS Trading Session Error - Initial Balance Property Missing",
"definition": {
"text": "A property called initialBalance is expeceted at the Session Base Asset and Session Quoted Asset Node config.",
"updated": 1611335687259
},
"paragraphs": [
{
"style": "Success",
"text": "Check the config at the Node reporting this error and make sure that this property exists. ",
"updated": 1611335725336
}
]
}
@@ -222,13 +222,22 @@
*/
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters === undefined) {
let errorMessage = "Session Node with no Parameters."
let errorMessage = "Parameters Node Missing"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(
processIndex,
TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE,
errorMessage
errorMessage,
docs
)
return false
}
@@ -247,18 +256,44 @@
/* Check that we received valid dates */
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.type === 'Backtesting Session') {
if (isNaN(new Date(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.initialDatetime)).valueOf()) {
let errorMessage = "sessionParameters.timeRange.config.initialDatetime is not a valid date."
let errorMessage = "Invalid Initial Datetime Property Value"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters, errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {
currentValue: {
style: "Json",
text: TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.initialDatetime
}
}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange, errorMessage, docs)
return false
}
}
if (isNaN(new Date(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.finalDatetime)).valueOf()) {
let errorMessage = "sessionParameters.timeRange.config.initialDatetime is not a valid date."
let errorMessage = "Invalid Initial Datetime Property Value"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters, errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {
currentValue: {
style: "Json",
text: TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange.config.finalDatetime
}
}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeRange, errorMessage, docs)
return false
}
}
@@ -318,57 +353,118 @@
/* Time Frame */
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame === undefined) {
let errorMessage = "Session Parameters Node with no Time Frame."
let errorMessage = "Time Frame Node Missing"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters, errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters, errorMessage, docs)
return false
}
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label === undefined) {
let errorMessage = "Session Parameters Node with no Time Frame Label configuration."
let errorMessage = "Label Property Missing"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame, errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame, errorMessage, docs)
return false
}
TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.value = getTimeFrameFromLabel(TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label)
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.value === undefined) {
let errorMessage = "Config error: label value not recognized. Try 01-min or 01-hs for example."
let errorMessage = "Invalid Label Property Value"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame, errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {
currentValue: {
style: "Json",
text: TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame.config.label
}
}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.timeFrame, errorMessage, docs)
return false
}
/* Session Base Asset */
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.sessionBaseAsset === undefined) {
let errorMessage = "Session Parameters Node with no Session Base Asset."
let errorMessage = "Session Base Asset Node Missing"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters, errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters, errorMessage, docs)
return false
}
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.sessionBaseAsset.config.initialBalance === undefined) {
let errorMessage = "Session Parameters Session Base Asset with no initialBalance configuration."
let errorMessage = "Initial Balance Property Missing"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.sessionBaseAsset, errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.sessionBaseAsset, errorMessage, docs)
return false
}
/* Session Quoted Asset */
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.sessionQuotedAsset === undefined) {
let errorMessage = "Session Parameters Node with no Session Quoted Asset."
let errorMessage = "Session Quoted Asset Node Missing"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters, errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters, errorMessage, docs)
return false
}
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.sessionQuotedAsset.config.initialBalance === undefined) {
let errorMessage = "Session Parameters Session Quoted Asset with no initialBalance configuration."
let errorMessage = "Initial Balance Property Missing"
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_INSTANCE_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
"[ERROR] initialize -> checkParemeters -> " + errorMessage)
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.sessionQuotedAsset, errorMessage)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS Trading Session Error - ' + errorMessage,
placeholder: {}
}
TS.projects.superalgos.functionLibraries.sessionFunctions.sessionError(processIndex, TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters.sessionQuotedAsset, errorMessage, docs)
return false
}
@@ -58,21 +58,24 @@ exports.newSuperalgosFunctionLibrariesSessionFunctions = function () {
}
}
function sessionError(processIndex, node, errorMessage) {
function sessionError(processIndex, node, errorMessage, docs) {
let event
if (node !== undefined) {
event = {
nodeName: node.name,
nodeType: node.type,
nodeId: node.id,
errorMessage: errorMessage
errorMessage: errorMessage,
docs: docs
}
} else {
event = {
errorMessage: errorMessage
errorMessage: errorMessage,
docs: docs
}
}
TS.projects.superalgos.globals.taskConstants.EVENT_SERVER_CLIENT_MODULE_OBJECT.raiseEvent(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_KEY, 'Error', event)
TS.projects.superalgos.globals.taskConstants.EVENT_SERVER_CLIENT_MODULE_OBJECT.raiseEvent(
TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_KEY, 'Error', event)
if (TS.projects.superalgos.globals.taskVariables.IS_TASK_STOPPING === true) {
TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).IS_SESSION_STOPPING = true
@@ -225,9 +225,9 @@ function newSuperalgosDocSpace() {
When an editor is on focus we will only
take care of a few combinations of key strokes
so as to tell the editor container when the user
would like to close the editor.
would like to close the editor. ESC key exits edit mode.
*/
if (event.key === 'Escape') {
if (event.key === 'Escape') {
UI.projects.superalgos.spaces.docsSpace.exitEditMode()
}
}
@@ -242,8 +242,8 @@ function newSuperalgosDocSpace() {
function exitEditMode() {
if (EDITOR_ON_FOCUS === true) {
thisObject.documentPage.exitEditMode()
EDITOR_ON_FOCUS = false
UI.projects.superalgos.spaces.docsSpace.documentPage.render()
EDITOR_ON_FOCUS = false
}
}