Merge pull request #468 from Luis-Fernando-Molina/develop
Contribution: Improvement of Error handling when reaching the Max or Min balance configured / Integration with the Docs
This commit is contained in:
7 files changed
+181
-11
No files matched your search
+34
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"topic": "TS LF Trading Bot Errors",
|
||||
"pageNumber": "5",
|
||||
"type": "TS LF Trading Bot Error - Maximum Balance Reached",
|
||||
"definition": {
|
||||
"text": "The execution of the Trading System was halted because the maximun balance configured was reached. ",
|
||||
"updated": 1611588526786
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "You are allowed to configure at the Session Base Asset and Session Quoted Asset nodes a maximum balance. If you do that -- because it is optional -- the LF Trading Bot will check at every candle during the Trading Simulation that the balance has not reached that maximum. If it does, this error is triggered and the Trading System stops it's execution inmediatelly.",
|
||||
"updated": 1611588663021
|
||||
},
|
||||
{
|
||||
"style": "Error",
|
||||
"text": "Maximum Balance Reached"
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Context Information"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "When this error happened, some context information was preserved for you to analyze. Following is that info:",
|
||||
"updated": 1611589752537
|
||||
},
|
||||
{
|
||||
"style": "Placeholder",
|
||||
"text": "contextInfo",
|
||||
"updated": 1611589783431
|
||||
}
|
||||
]
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"topic": "TS LF Trading Bot Errors",
|
||||
"pageNumber": "6",
|
||||
"type": "TS LF Trading Bot Error - Minimum Balance Reached",
|
||||
"definition": {
|
||||
"text": "The execution of the Trading System was halted because the minimun balance configured was reached. ",
|
||||
"updated": 1611588526786
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "You are allowed to configure at the Session Base Asset and Session Quoted Asset nodes a minimum balance. If you do that -- because it is optional -- the LF Trading Bot will check at every candle during the Trading Simulation that the balance has not reached that minimum. If it does, this error is triggered and the Trading System stops it's execution inmediatelly.",
|
||||
"updated": 1611588663021
|
||||
},
|
||||
{
|
||||
"style": "Error",
|
||||
"text": "Maximum Balance Reached"
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Context Information"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "When this error happened, some context information was preserved for you to analize. Following is that info:"
|
||||
},
|
||||
{
|
||||
"style": "Placeholder",
|
||||
"text": "contectInfo "
|
||||
}
|
||||
]
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"topic": "TS LF Trading Bot Errors",
|
||||
"pageNumber": "6",
|
||||
"type": "TS LF Trading Bot Error - Minimum Balance Reached",
|
||||
"definition": {
|
||||
"text": "The execution of the Trading System was halted because the minimun balance configured was reached. ",
|
||||
"updated": 1611588526786
|
||||
},
|
||||
"paragraphs": [
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "You are allowed to configure at the Session Base Asset and Session Quoted Asset nodes a minimum balance. If you do that -- because it is optional -- the LF Trading Bot will check at every candle during the Trading Simulation that the balance has not reached that minimum. If it does, this error is triggered and the Trading System stops it's execution inmediatelly.",
|
||||
"updated": 1611588663021
|
||||
},
|
||||
{
|
||||
"style": "Error",
|
||||
"text": "Maximum Balance Reached"
|
||||
},
|
||||
{
|
||||
"style": "Title",
|
||||
"text": "Context Information"
|
||||
},
|
||||
{
|
||||
"style": "Text",
|
||||
"text": "When this error happened, some context information was preserved for you to analyze. Following is that info:",
|
||||
"updated": 1611589734230
|
||||
},
|
||||
{
|
||||
"style": "Placeholder",
|
||||
"text": "contextInfo",
|
||||
"updated": 1611589581981
|
||||
}
|
||||
]
|
||||
}
|
||||
+72
-8
@@ -125,9 +125,9 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) {
|
||||
let candle = candles[tradingEngine.current.episode.candle.index.value]
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
|
||||
'[INFO] runSimulation -> loop -> Candle Begin @ ' + (new Date(candle.begin)).toLocaleString())
|
||||
'[INFO] runSimulation -> loop -> Candle Begin @ ' + (new Date(candle.begin)).toUTCString())
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
|
||||
'[INFO] runSimulation -> loop -> Candle End @ ' + (new Date(candle.end)).toLocaleString())
|
||||
'[INFO] runSimulation -> loop -> Candle End @ ' + (new Date(candle.end)).toUTCString())
|
||||
|
||||
TS.projects.superalgos.globals.processModuleObjects.MODULE_OBJECTS_BY_PROCESS_INDEX_MAP.get(processIndex).TRADING_ENGINE_MODULE_OBJECT.setCurrentCandle(candle) // We move the current candle we are standing at, to the trading engine data structure to make it available to anyone, including conditions and formulas.
|
||||
|
||||
@@ -139,7 +139,7 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) {
|
||||
|
||||
if (checkInitialDatetime() === false) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
|
||||
'[INFO] runSimulation -> loop -> Candle Before the Initia Date Time @ ' + (new Date(candle.begin)).toLocaleString())
|
||||
'[INFO] runSimulation -> loop -> Candle Before the Initia Date Time @ ' + (new Date(candle.begin)).toUTCString())
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -518,12 +518,28 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) {
|
||||
because there the balances have shifted from their resting position.
|
||||
*/
|
||||
|
||||
let stopRunningDate = (new Date(tradingEngine.current.episode.candle.begin.value)).toLocaleString()
|
||||
let stopRunningDate = (new Date(tradingEngine.current.episode.candle.begin.value)).toUTCString()
|
||||
|
||||
if (sessionParameters.sessionBaseAsset.config.minimumBalance !== undefined) {
|
||||
if (tradingEngine.current.episode.episodeBaseAsset.balance.value <= sessionParameters.sessionBaseAsset.config.minimumBalance) {
|
||||
const errorMessage = 'Min Balance reached @ ' + stopRunningDate
|
||||
tradingSystem.errors.push([tradingSystem.id, errorMessage])
|
||||
|
||||
let docs = {
|
||||
project: 'Superalgos',
|
||||
category: 'Topic',
|
||||
type: 'TS LF Trading Bot Error - Minimum Balance Reached',
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
let contextInfo = {
|
||||
timestamp: stopRunningDate,
|
||||
episodeBaseAssetBalance: tradingEngine.current.episode.episodeBaseAsset.balance.value,
|
||||
sessionBaseAssetMinimumBalance: sessionParameters.sessionBaseAsset.config.minimumBalance
|
||||
}
|
||||
|
||||
TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, undefined, undefined, undefined, undefined, undefined, contextInfo)
|
||||
|
||||
tradingSystem.errors.push([tradingSystem.id, errorMessage, docs])
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
|
||||
'[WARN] runSimulation -> checkMinimunAndMaximunBalance -> ' + errorMessage)
|
||||
return false
|
||||
@@ -533,7 +549,23 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) {
|
||||
if (sessionParameters.sessionBaseAsset.config.maximumBalance !== undefined) {
|
||||
if (tradingEngine.current.episode.episodeBaseAsset.balance.value >= sessionParameters.sessionBaseAsset.config.maximumBalance) {
|
||||
const errorMessage = 'Max Balance reached @ ' + stopRunningDate
|
||||
tradingSystem.errors.push([tradingSystem.id, errorMessage])
|
||||
|
||||
let docs = {
|
||||
project: 'Superalgos',
|
||||
category: 'Topic',
|
||||
type: 'TS LF Trading Bot Error - Maximum Balance Reached',
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
let contextInfo = {
|
||||
timestamp: stopRunningDate,
|
||||
episodeBaseAssetBalance: tradingEngine.current.episode.episodeBaseAsset.balance.value,
|
||||
sessionBaseAssetMaximumBalance: sessionParameters.sessionBaseAsset.config.maximumBalance
|
||||
}
|
||||
|
||||
TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, undefined, undefined, undefined, undefined, undefined, contextInfo)
|
||||
|
||||
tradingSystem.errors.push([tradingSystem.id, errorMessage, docs])
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
|
||||
'[WARN] runSimulation -> checkMinimunAndMaximunBalance -> ' + errorMessage)
|
||||
return false
|
||||
@@ -543,7 +575,23 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) {
|
||||
if (sessionParameters.sessionQuotedAsset.config.minimumBalance !== undefined) {
|
||||
if (tradingEngine.current.episode.episodeQuotedAsset.balance.value <= sessionParameters.sessionQuotedAsset.config.minimumBalance) {
|
||||
const errorMessage = 'Min Balance reached @ ' + stopRunningDate
|
||||
tradingSystem.errors.push([tradingSystem.id, errorMessage])
|
||||
|
||||
let docs = {
|
||||
project: 'Superalgos',
|
||||
category: 'Topic',
|
||||
type: 'TS LF Trading Bot Error - Minimum Balance Reached',
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
let contextInfo = {
|
||||
timestamp: stopRunningDate,
|
||||
episodeQuotedAssetBalance: tradingEngine.current.episode.episodeQuotedAsset.balance.value,
|
||||
sessionQuotedAssetMinimumBalance: sessionParameters.sessionQuotedAsset.config.minimumBalance
|
||||
}
|
||||
|
||||
TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, undefined, undefined, undefined, undefined, undefined, contextInfo)
|
||||
|
||||
tradingSystem.errors.push([tradingSystem.id, errorMessage, docs])
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
|
||||
'[WARN] runSimulation -> checkMinimunAndMaximunBalance -> ' + errorMessage)
|
||||
return false
|
||||
@@ -553,7 +601,23 @@ exports.newSuperalgosBotModulesTradingSimulation = function (processIndex) {
|
||||
if (sessionParameters.sessionQuotedAsset.config.maximumBalance !== undefined) {
|
||||
if (tradingEngine.current.episode.episodeQuotedAsset.balance.value >= sessionParameters.sessionQuotedAsset.config.maximumBalance) {
|
||||
const errorMessage = 'Max Balance reached @ ' + stopRunningDate
|
||||
tradingSystem.errors.push([tradingSystem.id, errorMessage])
|
||||
|
||||
let docs = {
|
||||
project: 'Superalgos',
|
||||
category: 'Topic',
|
||||
type: 'TS LF Trading Bot Error - Maximum Balance Reached',
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
let contextInfo = {
|
||||
timestamp: stopRunningDate,
|
||||
episodeQuotedAssetBalance: tradingEngine.current.episode.episodeQuotedAsset.balance.value,
|
||||
sessionQuotedAssetMaximumBalance: sessionParameters.sessionQuotedAsset.config.maximumBalance
|
||||
}
|
||||
|
||||
TS.projects.superalgos.utilities.docsFunctions.buildPlaceholder(docs, undefined, undefined, undefined, undefined, undefined, contextInfo)
|
||||
|
||||
tradingSystem.errors.push([tradingSystem.id, errorMessage, docs])
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE_OBJECT.write(MODULE_NAME,
|
||||
'[WARN] runSimulation -> checkMinimunAndMaximunBalance -> ' + errorMessage)
|
||||
return false
|
||||
|
||||
@@ -6,7 +6,7 @@ exports.newSuperalgosUtilitiesDocsFunctions = function () {
|
||||
|
||||
return thisObject
|
||||
|
||||
function buildPlaceholder(docs, error, nodeName, nodeCode, nodeConfig, nodeValue) {
|
||||
function buildPlaceholder(docs, error, nodeName, nodeCode, nodeConfig, nodeValue, contextInfo) {
|
||||
if (error !== undefined) {
|
||||
if (error.message !== undefined) {
|
||||
docs.placeholder.errorMessage = {
|
||||
@@ -56,5 +56,11 @@ exports.newSuperalgosUtilitiesDocsFunctions = function () {
|
||||
text: nodeValue
|
||||
}
|
||||
}
|
||||
if (contextInfo !== undefined) {
|
||||
docs.placeholder.contextInfo = {
|
||||
style: 'Json',
|
||||
text: JSON.stringify(contextInfo, undefined, 4)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -558,7 +558,7 @@ function newRateScale() {
|
||||
|
||||
let labelArray = label.split('.')
|
||||
let label1 = thisObject.payload.node.payload.parentNode.name
|
||||
let label2 = (Math.trunc(rate)).toLocaleString()
|
||||
let label2 = (Math.trunc(rate)).toUTCString()
|
||||
let label3 = labelArray[1]
|
||||
if (label3 === undefined) { label3 = '00' }
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ function newSuperalgosUtilitiesDrawPrint() {
|
||||
if (fixedDecimals !== true) {
|
||||
label = dynamicDecimals(labelToPrint, minDecimals)
|
||||
}
|
||||
label = label.toLocaleString()
|
||||
label = label.toUTCString()
|
||||
if (noDecimals === true) {
|
||||
label = Math.trunc(label)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user