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

Contribution: Trading Order Error Handling Improved / Integrated with the Docs
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-01-26 10:40:28 +01:00
commit 14081eb442
44 files changed
+775 -47

No files matched your search

@@ -0,0 +1,15 @@
{
"topic": "Error Causes",
"pageNumber": "1",
"type": "Reference Missing",
"definition": {
"text": "You will get an error of this type every time a Node that is expected to reference some other node and no reference was found. You can usually avoid this type of errors by setting up the expected reference.",
"updated": 1611652038378
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository."
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "Error Causes",
"pageNumber": "2",
"type": "Node Missing",
"definition": {
"text": "You will get this type of errors every time a Node is expected as a child of another Node but it is not found. To avoid this type of errors, add the missing Node as a child of the Node where this type of error pops up.",
"updated": 1611652119353
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository."
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "Error Causes",
"pageNumber": "3",
"type": "Value Not A Number",
"definition": {
"text": "At runtime some nodes might aquire a value, and when it is expected that the value is a number, this type of error will pop up. To avoid this to happen make yourself sure that at nodes that should have only numeric values, that they don't get by any means a non numeric one.",
"updated": 1611652261727
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository."
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "Error Causes",
"pageNumber": "4",
"type": "Value Undefined",
"definition": {
"text": "Some nodes might aquire a value at runtime. This type of error will pop up when such a node is expected to have some value but it has none. Undefined means no value at all of any type.",
"updated": 1611652326745
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository."
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "Error Causes",
"pageNumber": "5",
"type": "Value Zero",
"definition": {
"text": "At runtime some nodes might aquire a value, and when it is expected not to be zero this type of error will pop up. To avoid this type of error, make yourself sure that the Node where the error poped up never get a zero value.",
"updated": 1611652416098
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository."
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "Error Causes",
"pageNumber": "6",
"type": "Value Zero Or Negative",
"definition": {
"text": "At runtime some nodes might aquire a value, and when it is expected not to be zero or negative this type of error will pop up. To avoid this type of error, make yourself sure that the Node where the error poped up never get a zero or negative value.",
"updated": 1611652451957
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository."
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "Error Causes",
"pageNumber": "7",
"type": "Property Missing",
"definition": {
"text": "This type of error means that a property at the config of a node is expected but was not found there. To avoid this type of errors, check the node's config and add the missing property.",
"updated": 1611652513029
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository."
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "Error Causes",
"pageNumber": "8",
"type": "Property Not A Number",
"definition": {
"text": "This type of error means that a property at the config of a node is expected to be a number but the value there it is not. To avoid this type of errors, check the node's config and make yourself sure that the property mentioned is indeed a number.",
"updated": 1611652575431
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use doscs.save to save your changes and app.contribute to send it to the main repository."
}
]
}
@@ -8,9 +8,9 @@
},
"paragraphs": [
{
"style": "Text",
"text": "This error happens when the conditions to switch phases are met but the LF Trading Bot cannot find a reference to the Phase where it should switch to.",
"updated": 1611581092289
"style": "Error",
"text": "Reference to Phase Node Missing",
"updated": 1611652631671
},
{
"style": "Success",
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "15",
"type": "TS LF Trading Bot Error - Order Reference Missing",
"definition": {
"text": "Each order at the Trading System is expected to have a reference to an order at the Trading Engine Data Structure. This references tells the system where to track at runtime the values of the order properties while the bot is running.",
"updated": 1611649597701
},
"paragraphs": [
{
"style": "Error",
"text": "Order Reference Missing",
"updated": 1611649632142
},
{
"style": "Success",
"text": "Set up the reference to an order of the Trading Engine and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "16",
"type": "TS LF Trading Bot Error - Status Node Missing",
"definition": {
"text": "A Status Node was expected but not found at the node where the error poped up.",
"updated": 1611649715787
},
"paragraphs": [
{
"style": "Error",
"text": "Status Node Missing",
"updated": 1611650236471
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,19 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "17",
"type": "TS LF Trading Bot Error - Percentage Of Algorithm Size Property Missing",
"definition": {
"text": "Write a summary for this topic page."
},
"paragraphs": [
{
"style": "Error",
"text": "Percentage Of Algorithm Size Property Missing",
"updated": 1611651040820
},
{
"style": "Success",
"text": "Add the missing property and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "18",
"type": "TS LF Trading Bot Error - Serial Number Node Missing",
"definition": {
"text": "A Serial Number Node was expected but not found at the node where the error poped up.",
"updated": 1611649736116
},
"paragraphs": [
{
"style": "Error",
"text": "Serial Number Node Missing",
"updated": 1611650268159
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "19",
"type": "TS LF Trading Bot Error - Identifier Node Missing",
"definition": {
"text": "A Identifier Node was expected but not found at the node where the error poped up.",
"updated": 1611649754630
},
"paragraphs": [
{
"style": "Error",
"text": "Identifier Node Missing",
"updated": 1611650286710
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "20",
"type": "TS LF Trading Bot Error - Exchange Id Node Missing",
"definition": {
"text": "A Exchange Id Node was expected but not found at the node where the error poped up.",
"updated": 1611649774326
},
"paragraphs": [
{
"style": "Error",
"text": "Exchange Id Node Missing",
"updated": 1611650307237
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "21",
"type": "TS LF Trading Bot Error - Begin Node Missing",
"definition": {
"text": "A Begin Node was expected but not found at the node where the error poped up.",
"updated": 1611649790597
},
"paragraphs": [
{
"style": "Error",
"text": "Begin Node Missing",
"updated": 1611650355892
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "22",
"type": "TS LF Trading Bot Error - End Node Missing",
"definition": {
"text": "A End Node was expected but not found at the node where the error poped up.",
"updated": 1611649805035
},
"paragraphs": [
{
"style": "Error",
"text": "End Node Missing",
"updated": 1611650377127
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "23",
"type": "TS LF Trading Bot Error - Rate Node Missing",
"definition": {
"text": "A Rate Node was expected but not found at the node where the error poped up.",
"updated": 1611649820795
},
"paragraphs": [
{
"style": "Error",
"text": "Rate Node Missing",
"updated": 1611650403594
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "24",
"type": "TS LF Trading Bot Error - Algorithm Name Node Missing",
"definition": {
"text": "An Algorithm Name Node was expected but not found at the node where the error poped up.",
"updated": 1611649859527
},
"paragraphs": [
{
"style": "Error",
"text": "Algorithm Name Node Missing",
"updated": 1611650424447
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "25",
"type": "TS LF Trading Bot Error - Order Counters Node Missing",
"definition": {
"text": "An Order Counters Node was expected but not found at the node where the error poped up.",
"updated": 1611649880412
},
"paragraphs": [
{
"style": "Error",
"text": "Order Counters Node Missing",
"updated": 1611650444896
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "26",
"type": "TS LF Trading Bot Error - Periods Node Missing",
"definition": {
"text": "A Periods Node was expected but not found at the node where the error poped up.",
"updated": 1611649909128
},
"paragraphs": [
{
"style": "Error",
"text": "Periods Node Missing",
"updated": 1611650660325
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "27",
"type": "TS LF Trading Bot Error - Order Statistics Node Missing",
"definition": {
"text": "An Order Statistics Node was expected but not found at the node where the error poped up.",
"updated": 1611649929741
},
"paragraphs": [
{
"style": "Error",
"text": "Order Statistics Node Misssing",
"updated": 1611650682469
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "28",
"type": "TS LF Trading Bot Error - Days Node Missing",
"definition": {
"text": "A Days Node was expected but not found at the node where the error poped up.",
"updated": 1611649947641
},
"paragraphs": [
{
"style": "Error",
"text": "Days Node Missing",
"updated": 1611650706769
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "29",
"type": "TS LF Trading Bot Error - Percentage Filled Node Missing",
"definition": {
"text": "A Percentage Filled Node was expected but not found at the node where the error poped up.",
"updated": 1611649967038
},
"paragraphs": [
{
"style": "Error",
"text": "Percentage Filled Node Missing",
"updated": 1611650726302
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "30",
"type": "TS LF Trading Bot Error - Actual Rate Node Missing",
"definition": {
"text": "A Actual Rate Node was expected but not found at the node where the error poped up.",
"updated": 1611649989038
},
"paragraphs": [
{
"style": "Error",
"text": "Rate Node Missing",
"updated": 1611650744510
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "31",
"type": "TS LF Trading Bot Error - Order Base Asset Node Missing",
"definition": {
"text": "An Order Base Asset Node was expected but not found at the node where the error poped up.",
"updated": 1611650015208
},
"paragraphs": [
{
"style": "Error",
"text": "Order Base Asset Node Missing",
"updated": 1611650767027
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "32",
"type": "TS LF Trading Bot Error - Size Node Missing",
"definition": {
"text": "A Size Node was expected but not found at the node where the error poped up.",
"updated": 1611650035884
},
"paragraphs": [
{
"style": "Error",
"text": "Size Node Missing",
"updated": 1611650784941
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "33",
"type": "TS LF Trading Bot Error - Size Filled Node Missing",
"definition": {
"text": "A Size Filled Node was expected but not found at the node where the error poped up.",
"updated": 1611650056396
},
"paragraphs": [
{
"style": "Error",
"text": "Size Filled Node Missing",
"updated": 1611650810373
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "34",
"type": "TS LF Trading Bot Error - Fees Paid Node Missing",
"definition": {
"text": "A Fees Paid Node was expected but not found at the node where the error poped up.",
"updated": 1611650080043
},
"paragraphs": [
{
"style": "Error",
"text": "Fees Paid Node Missing",
"updated": 1611650830751
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "35",
"type": "TS LF Trading Bot Error - Actual Size Node Missing",
"definition": {
"text": "An Actual Size Node was expected but not found at the node where the error poped up.",
"updated": 1611650100230
},
"paragraphs": [
{
"style": "Error",
"text": "Actual Size Node Missing",
"updated": 1611650850857
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "36",
"type": "TS LF Trading Bot Error - Amount Received Node Missing",
"definition": {
"text": "A Amount Received Node was expected but not found at the node where the error poped up.",
"updated": 1611650122772
},
"paragraphs": [
{
"style": "Error",
"text": "Amount Received Node Missing",
"updated": 1611650872000
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "37",
"type": "TS LF Trading Bot Error - Fees To Be Paid Node Missing",
"definition": {
"text": "A Fees To Be Paid Node was expected but not found at the node where the error poped up.",
"updated": 1611650142288
},
"paragraphs": [
{
"style": "Error",
"text": "Fees To Be Paid Node Missing",
"updated": 1611650893565
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "38",
"type": "TS LF Trading Bot Error - Order Quoted Asset Node Missing",
"definition": {
"text": "A Order Quoted Asset Node was expected but not found at the node where the error poped up.",
"updated": 1611650168650
},
"paragraphs": [
{
"style": "Error",
"text": "Order Quoted Asset Node Missing",
"updated": 1611650915963
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,20 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "39",
"type": "TS LF Trading Bot Error - Order Rate Node Missing",
"definition": {
"text": "A Order Rate Node was expected but not found at the node where the error poped up.",
"updated": 1611650190281
},
"paragraphs": [
{
"style": "Error",
"text": "Order Rate Node Missing",
"updated": 1611650934529
},
{
"style": "Success",
"text": "Add the missing node and try again."
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "40",
"type": "TS LF Trading Bot Error - Rate Value Undefined",
"definition": {
"text": "Write a summary for this topic page."
},
"paragraphs": [
{
"style": "Error",
"text": "Rate Value Undefined",
"updated": 1611651100958
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "41",
"type": "TS LF Trading Bot Error - Rate Value Not A Number",
"definition": {
"text": "Write a summary for this topic page."
},
"paragraphs": [
{
"style": "Error",
"text": "Rate Value Not A Number",
"updated": 1611651124687
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "42",
"type": "TS LF Trading Bot Error - Rate Value Zero Or Negative",
"definition": {
"text": "Write a summary for this topic page."
},
"paragraphs": [
{
"style": "Error",
"text": "Rate Value Zero Or Negative",
"updated": 1611651177927
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "43",
"type": "TS LF Trading Bot Error - Percentage Of Stage Target Size Property Missing",
"definition": {
"text": "Write a summary for this topic page."
},
"paragraphs": [
{
"style": "Error",
"text": "Percentage Of Stage Target Size Property Missing",
"updated": 1611651247391
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "44",
"type": "TS LF Trading Bot Error - Percentage Of Stage Target Size Property Not A Number",
"definition": {
"text": "Write a summary for this topic page."
},
"paragraphs": [
{
"style": "Error",
"text": "Percentage Of Stage Target Size Property Not A Number",
"updated": 1611651274703
}
]
}
@@ -0,0 +1,15 @@
{
"topic": "TS LF Trading Bot Errors",
"pageNumber": "45",
"type": "TS LF Trading Bot Error - Percentage Of Algorithm Size Property Not A Number",
"definition": {
"text": "Write a summary for this topic page."
},
"paragraphs": [
{
"style": "Error",
"text": "Percentage Of Algorithm Size Property Not A Number",
"updated": 1611651354529
}
]
}
@@ -75,8 +75,10 @@ exports.newSuperalgosBotModulesTradingExecution = function (processIndex) {
}
} catch (err) {
tradingSystem.errors.push([executionNode.id, err.message])
if (err !== 'Error Already Recorded') {
tradingSystem.errors.push([executionNode.id, err.message])
}
if (typeof err === 'string' || err instanceof String) {
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, '[ERROR] runExecution -> err = ' + err)
}
@@ -88,12 +88,12 @@ exports.newSuperalgosBotModulesTradingOrders = function (processIndex) {
for (let i = 0; i < orders.length; i++) {
let tradingSystemOrder = orders[i]
if (tradingSystemOrder.referenceParent === undefined) {
badDefinitionUnhandledException(undefined, 'tradingSystemOrder.referenceParent === undefined', tradingSystemOrder)
badDefinitionUnhandledException(undefined, 'Order Reference Missing', tradingSystemOrder)
}
let tradingEngineOrder = TS.projects.superalgos.globals.processModuleObjects.MODULE_OBJECTS_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_ENGINE_MODULE_OBJECT.getNodeById(tradingSystemOrder.referenceParent.id)
if (tradingEngineOrder.status === undefined) {
badDefinitionUnhandledException(undefined, 'tradingEngineOrder.status === undefined', tradingEngineOrder)
badDefinitionUnhandledException(undefined, 'Status Node Missing', tradingEngineOrder)
}
if (mantain === true) {
@@ -220,39 +220,44 @@ exports.newSuperalgosBotModulesTradingOrders = function (processIndex) {
function tradingSystemValidations(tradingSystemOrder) {
/* Trading System Validations */
if (tradingSystemOrder.config.percentageOfAlgorithmSize === undefined) { badDefinitionUnhandledException(undefined, 'tradingSystemOrder.config.percentageOfAlgorithmSize === undefined', tradingSystemOrder) }
if (tradingSystemOrder.referenceParent === undefined) { badDefinitionUnhandledException(undefined, 'tradingSystemOrder.referenceParent === undefined', tradingSystemOrder) }
if (tradingSystemOrder.config.percentageOfAlgorithmSize === undefined) { badDefinitionUnhandledException(undefined, 'Percentage Of Algorithm Size Property Missing', tradingSystemOrder) }
if (tradingSystemOrder.referenceParent === undefined) { badDefinitionUnhandledException(undefined, 'Order Reference Missing', tradingSystemOrder) }
}
function tradingEngineValidations(tradingEngineOrder) {
/* Trading Engine Order Validations */
if (tradingEngineOrder.serialNumber === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.serialNumber === undefined', tradingEngineOrder) }
if (tradingEngineOrder.identifier === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.identifier === undefined', tradingEngineOrder) }
if (tradingEngineOrder.exchangeId === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.exchangeId === undefined', tradingEngineOrder) }
if (tradingEngineOrder.begin === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.begin === undefined', tradingEngineOrder) }
if (tradingEngineOrder.end === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.end === undefined', tradingEngineOrder) }
if (tradingEngineOrder.rate === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.rate === undefined', tradingEngineOrder) }
if (tradingEngineOrder.status === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.status === undefined', tradingEngineOrder) }
if (tradingEngineOrder.algorithmName === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.algorithmName === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderCounters === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderCounters === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderCounters.periods === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderCounters.periods === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderStatistics.days === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderStatistics.days === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderStatistics.percentageFilled === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderStatistics.percentageFilled === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderStatistics.actualRate === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderStatistics.actualRate === undefined', tradingEngineOrder) }
if (tradingEngineOrder.serialNumber === undefined) { badDefinitionUnhandledException(undefined, 'Serial Number Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.identifier === undefined) { badDefinitionUnhandledException(undefined, 'Identifier Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.exchangeId === undefined) { badDefinitionUnhandledException(undefined, 'Exchange Id Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.begin === undefined) { badDefinitionUnhandledException(undefined, 'Begin Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.end === undefined) { badDefinitionUnhandledException(undefined, 'End Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.rate === undefined) { badDefinitionUnhandledException(undefined, 'Rate Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.status === undefined) { badDefinitionUnhandledException(undefined, 'Status Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.algorithmName === undefined) { badDefinitionUnhandledException(undefined, 'Algorithm Name Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.orderCounters === undefined) { badDefinitionUnhandledException(undefined, 'Order Counters Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.orderCounters.periods === undefined) { badDefinitionUnhandledException(undefined, 'Periods Node Missing', tradingEngineOrder.orderCounters) }
if (tradingEngineOrder.orderBaseAsset.size === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderBaseAsset.size === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderBaseAsset.sizeFilled === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderBaseAsset.sizeFilled === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderBaseAsset.feesPaid === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderBaseAsset.feesPaid === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderBaseAsset.actualSize === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderBaseAsset.actualSize === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderBaseAsset.amountReceived === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderBaseAsset.amountReceived === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderBaseAsset.feesToBePaid === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderBaseAsset.feesToBePaid === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderStatistics === undefined) { badDefinitionUnhandledException(undefined, 'Order Statistics Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.orderStatistics.days === undefined) { badDefinitionUnhandledException(undefined, 'Days Node Missing', tradingEngineOrder.orderStatistics) }
if (tradingEngineOrder.orderStatistics.percentageFilled === undefined) { badDefinitionUnhandledException(undefined, 'Percentage Filled Node Missing', tradingEngineOrder.orderStatistics) }
if (tradingEngineOrder.orderStatistics.actualRate === undefined) { badDefinitionUnhandledException(undefined, 'Actual Rate Node Missing', tradingEngineOrder.orderStatistics) }
if (tradingEngineOrder.orderQuotedAsset.size === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderQuotedAsset.size === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderQuotedAsset.sizeFilled === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderQuotedAsset.sizeFilled === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderQuotedAsset.feesPaid === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderQuotedAsset.feesPaid === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderQuotedAsset.actualSize === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderQuotedAsset.actualSize === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderQuotedAsset.amountReceived === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderQuotedAsset.amountReceived === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderQuotedAsset.feesToBePaid === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.orderQuotedAsset.feesToBePaid === undefined', tradingEngineOrder) }
if (tradingEngineOrder.orderBaseAsset === undefined) { badDefinitionUnhandledException(undefined, 'Order Base Asset Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.orderBaseAsset.size === undefined) { badDefinitionUnhandledException(undefined, 'Size Node Missing', tradingEngineOrder.orderBaseAsset) }
if (tradingEngineOrder.orderBaseAsset.sizeFilled === undefined) { badDefinitionUnhandledException(undefined, 'Size Filled Node Missing', tradingEngineOrder.orderBaseAsset) }
if (tradingEngineOrder.orderBaseAsset.feesPaid === undefined) { badDefinitionUnhandledException(undefined, 'Fees Paid Node Missing', tradingEngineOrder.orderBaseAsset) }
if (tradingEngineOrder.orderBaseAsset.actualSize === undefined) { badDefinitionUnhandledException(undefined, 'Actual Size Node Missing', tradingEngineOrder.orderBaseAsset) }
if (tradingEngineOrder.orderBaseAsset.amountReceived === undefined) { badDefinitionUnhandledException(undefined, 'Amount Received Node Missing', tradingEngineOrder.orderBaseAsset) }
if (tradingEngineOrder.orderBaseAsset.feesToBePaid === undefined) { badDefinitionUnhandledException(undefined, 'Fees To Be Paid Node Missing', tradingEngineOrder.orderBaseAsset) }
if (tradingEngineOrder.orderQuotedAsset === undefined) { badDefinitionUnhandledException(undefined, 'Order Quoted Asset Node Missing', tradingEngineOrder) }
if (tradingEngineOrder.orderQuotedAsset.size === undefined) { badDefinitionUnhandledException(undefined, 'Size Node Missing', tradingEngineOrder.orderQuotedAsset) }
if (tradingEngineOrder.orderQuotedAsset.sizeFilled === undefined) { badDefinitionUnhandledException(undefined, 'Size Filled Node Missing', tradingEngineOrder.orderQuotedAsset) }
if (tradingEngineOrder.orderQuotedAsset.feesPaid === undefined) { badDefinitionUnhandledException(undefined, 'Fees Paid Node Missing', tradingEngineOrder.orderQuotedAsset) }
if (tradingEngineOrder.orderQuotedAsset.actualSize === undefined) { badDefinitionUnhandledException(undefined, 'Actual Size Node Missing', tradingEngineOrder.orderQuotedAsset) }
if (tradingEngineOrder.orderQuotedAsset.amountReceived === undefined) { badDefinitionUnhandledException(undefined, 'Amount Received Node Missing', tradingEngineOrder.orderQuotedAsset) }
if (tradingEngineOrder.orderQuotedAsset.feesToBePaid === undefined) { badDefinitionUnhandledException(undefined, 'Fees To Be Paid Node Missing', tradingEngineOrder.orderQuotedAsset) }
}
async function tryToOpenOrder(tradingEngineStage, executionAlgorithm, tradingSystemOrder, tradingEngineOrder, situationName) {
@@ -319,16 +324,16 @@ exports.newSuperalgosBotModulesTradingOrders = function (processIndex) {
/* Optional Rate Definition */
if (tradingSystemOrder.type === 'Limit Buy Order' || tradingSystemOrder.type === 'Limit Sell Order') {
if (tradingSystemOrder.orderRate === undefined) { badDefinitionUnhandledException(undefined, 'tradingSystemOrder.orderRate === undefined', tradingSystemOrder) }
if (tradingSystemOrder.orderRate.formula === undefined) { badDefinitionUnhandledException(undefined, 'tradingSystemOrder.orderRate.formula === undefined', tradingSystemOrder) }
if (tradingSystemOrder.orderRate === undefined) { badDefinitionUnhandledException(undefined, 'Order Rate Node Missing', tradingSystemOrder) }
if (tradingSystemOrder.orderRate.formula === undefined) { badDefinitionUnhandledException(undefined, 'Formula Node Missing', tradingSystemOrder) }
/* Extract the rate value from the user-defined formula */
tradingEngineOrder.rate.value = tradingSystem.formulas.get(tradingSystemOrder.orderRate.formula.id)
/* Final rate validations */
if (tradingEngineOrder.rate.value === undefined) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.rate.value === undefined', tradingSystemOrder) }
if (isNaN(tradingEngineOrder.rate.value) === true) { badDefinitionUnhandledException(undefined, 'isNaN(tradingEngineOrder.rate.value) === true', tradingSystemOrder) }
if (tradingEngineOrder.rate.value <= 0) { badDefinitionUnhandledException(undefined, 'tradingEngineOrder.rate.value <= 0', tradingSystemOrder) }
if (tradingEngineOrder.rate.value === undefined) { badDefinitionUnhandledException(undefined, 'Rate Value Undefined', tradingEngineOrder.rate) }
if (isNaN(tradingEngineOrder.rate.value) === true) { badDefinitionUnhandledException(undefined, 'Rate Value Not A Number', tradingSystemOrder) }
if (tradingEngineOrder.rate.value <= 0) { badDefinitionUnhandledException(undefined, 'Rate Value Zero Or Negative', tradingSystemOrder) }
tradingEngineOrder.rate.value = TS.projects.superalgos.utilities.miscellaneousFunctions.truncateToThisPrecision(tradingEngineOrder.rate.value, 10)
} else {
@@ -351,10 +356,10 @@ exports.newSuperalgosBotModulesTradingOrders = function (processIndex) {
function requiredConfigurationValidation() {
/* Validate that this config exists */
if (executionAlgorithm.config.percentageOfStageTargetSize === undefined) {
badDefinitionUnhandledException(undefined, 'executionAlgorithm.config.percentageOfStageTargetSize === undefined', executionAlgorithm)
badDefinitionUnhandledException(undefined, 'Percentage Of Stage Target Size Property Missing', executionAlgorithm)
}
if (isNaN(executionAlgorithm.config.percentageOfStageTargetSize) === true) {
badDefinitionUnhandledException(undefined, 'isNaN(executionAlgorithm.config.percentageOfStageTargetSize) === true', executionAlgorithm)
badDefinitionUnhandledException(undefined, 'Percentage Of Stage Target Size Property Not A Number', executionAlgorithm)
}
algorithmSizeInBaseAsset = tradingEngineStage.stageBaseAsset.targetSize.value * executionAlgorithm.config.percentageOfStageTargetSize / 100
@@ -362,10 +367,10 @@ exports.newSuperalgosBotModulesTradingOrders = function (processIndex) {
/* Validate that this config exists */
if (tradingSystemOrder.config.percentageOfAlgorithmSize === undefined) {
badDefinitionUnhandledException(undefined, 'tradingSystemOrder.config.percentageOfAlgorithmSize === undefined', tradingSystemOrder)
badDefinitionUnhandledException(undefined, 'Percentage Of Algorithm Size Property Missing', tradingSystemOrder)
}
if (isNaN(tradingSystemOrder.config.percentageOfAlgorithmSize) === true) {
badDefinitionUnhandledException(undefined, 'isNaN(tradingSystemOrder.config.percentageOfAlgorithmSize) === true', tradingSystemOrder)
badDefinitionUnhandledException(undefined, 'Percentage Of Algorithm Size Property Not A Number', tradingSystemOrder)
}
}
@@ -1061,7 +1066,15 @@ exports.newSuperalgosBotModulesTradingOrders = function (processIndex) {
}
function badDefinitionUnhandledException(err, message, node) {
tradingSystem.errors.push([node.id, message])
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'TS LF Trading Bot Error - ' + message,
placeholder: {}
}
tradingSystem.errors.push([node.id, message, docs])
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> " + message);
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> node.name = " + node.name);
@@ -1070,7 +1083,11 @@ exports.newSuperalgosBotModulesTradingOrders = function (processIndex) {
if (err !== undefined) {
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME, "[ERROR] -> err.stack = " + err.stack);
}
throw 'Please fix the problem and try again.'
/*
Now we are going to abort this execution and jump to the latest error handler
signaling that we already recorded the error to avoid duplicates.
*/
throw 'Error Already Recorded'
}
}
@@ -558,7 +558,7 @@ function newRateScale() {
let labelArray = label.split('.')
let label1 = thisObject.payload.node.payload.parentNode.name
let label2 = (Math.trunc(rate)).toUTCString()
let label2 = (Math.trunc(rate)).toLocaleString()
let label3 = labelArray[1]
if (label3 === undefined) { label3 = '00' }
@@ -224,7 +224,7 @@ function newSuperalgosUtilitiesDrawPrint() {
if (fixedDecimals !== true) {
label = dynamicDecimals(labelToPrint, minDecimals)
}
label = label.toUTCString()
label = label.toLocaleString()
if (noDecimals === true) {
label = Math.trunc(label)
}