From 9ba95a5b336523335b29c31e48ec7b7aa460857e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Jul 2020 09:26:13 +0200 Subject: [PATCH] Fix Chart is not Defined --- AppSchema.json | 15 ++++++++++++++- TaskServer/LowFrequencyTrading/Announcements.js | 6 +----- TaskServer/LowFrequencyTrading/TradingSystem.js | 8 ++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/AppSchema.json b/AppSchema.json index 0f15c2bd7..385994d7f 100644 --- a/AppSchema.json +++ b/AppSchema.json @@ -1428,6 +1428,14 @@ "relatedUiObject": "Condition", "actionFunction": "payload.onMenuItemClick" }, + { + "action": "Add UI Object", + "disableIfPropertyIsDefined": true, + "propertyToCheckFor": "formula", + "label": "Add Formula", + "relatedUiObject": "Formula", + "actionFunction": "payload.onMenuItemClick" + }, { "action": "Delete UI Object", "askConfirmation": true, @@ -1450,6 +1458,11 @@ "type": "array", "childType": "Condition", "autoAdd": true + }, + { + "name": "formula", + "type": "node", + "childType": "Formula" } ], "propertyNameAtParent": "situations" @@ -8247,7 +8260,7 @@ }, "level": 4, "chainAttachesTo": { - "compatibleTypes": "->Position Size->Position Rate->Phase->Announcement->Record Property->Simulated Actual Rate->" + "compatibleTypes": "->Position Size->Position Rate->Phase->Announcement->Record Property->Simulated Actual Rate->Situation->" }, "icon": "pipette", "propertyNameAtParent": "formula" diff --git a/TaskServer/LowFrequencyTrading/Announcements.js b/TaskServer/LowFrequencyTrading/Announcements.js index ec8c25d75..2c63c88d1 100644 --- a/TaskServer/LowFrequencyTrading/Announcements.js +++ b/TaskServer/LowFrequencyTrading/Announcements.js @@ -41,11 +41,7 @@ exports.newAnnouncements = function newAnnouncements(bot, logger) { if (canAnnounce === true) { let text = announcement.config.text if (announcement.formula !== undefined) { - try { - text = eval(announcement.formula.code) - } catch (err) { - tradingSystem.errors.push([announcement.formula.id, err.message]) - } + text = tradingSystem.formulas.get(announcement.formula.id) } if (bot.SESSION.socialBots !== undefined) { diff --git a/TaskServer/LowFrequencyTrading/TradingSystem.js b/TaskServer/LowFrequencyTrading/TradingSystem.js index 64670330d..a1755803f 100644 --- a/TaskServer/LowFrequencyTrading/TradingSystem.js +++ b/TaskServer/LowFrequencyTrading/TradingSystem.js @@ -656,6 +656,14 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM evalConditions(manageStage, 'Manage Stage') evalFormulas(manageStage, 'Manage Stage') + if ( + tradingEngine.current.position.stopLoss.stopLossStage.value === 'Open Stage' || + tradingEngine.current.position.takeProfit.takeProfitStage.value === 'Open Stage') { + let stageNode = tradingSystem.tradingStrategies[tradingEngine.current.strategy.index.value].openStage + evalConditions(stageNode, 'Initial Definition') + evalFormulas(stageNode, 'Initial Definition') + } + /* Stop Loss Management */ checkStopPhasesEvents() calculateStopLoss()