From 11aa3d6bf7d9864cc6359a2c97fed1006ada2bf2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 6 Aug 2020 11:45:01 +0200 Subject: [PATCH] Bug Fixes --- LowFrequencyTrading/TradingStages.js | 5 +++-- LowFrequencyTrading/TradingSystem.js | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/LowFrequencyTrading/TradingStages.js b/LowFrequencyTrading/TradingStages.js index 809d63361..0acd5488e 100644 --- a/LowFrequencyTrading/TradingStages.js +++ b/LowFrequencyTrading/TradingStages.js @@ -586,7 +586,7 @@ exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineM the Position Rate, and we assign the values Above or Below to it. */ if (tradingEngine.current.position.stopLoss.stopLossPosition.value === tradingEngine.current.position.stopLoss.stopLossPosition.config.initialValue) { - if (tradingEngine.current.position.stopLoss.value > tradingEngine.current.position.rate.value) { + if (tradingEngine.current.position.stopLoss.value > tradingEngine.current.position.entryTargetRate.value) { tradingEngine.current.position.stopLoss.stopLossPosition.value = 'Above' } else { tradingEngine.current.position.stopLoss.stopLossPosition.value = 'Below' @@ -602,7 +602,7 @@ exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineM the Position Rates, and we assign the values Above or Below to it. */ if (tradingEngine.current.position.takeProfit.takeProfitPosition.value === tradingEngine.current.position.takeProfit.takeProfitPosition.config.initialValue) { - if (tradingEngine.current.position.takeProfit.value > tradingEngine.current.position.rate.value) { + if (tradingEngine.current.position.takeProfit.value > tradingEngine.current.position.entryTargetRate.value) { tradingEngine.current.position.takeProfit.takeProfitPosition.value = 'Above' } else { tradingEngine.current.position.takeProfit.takeProfitPosition.value = 'Below' @@ -885,6 +885,7 @@ exports.newTradingStages = function newTradingStages(bot, logger, tradingEngineM the total filled size of the Open Stage. By skiping execution now we allow the open stage to get a final value for sizeFilled that we can use. */ + let stageNode = tradingSystem.tradingStrategies[tradingEngine.current.strategy.index.value].closeStage /* Exit Position size and rate */ tradingSystem.evalFormulas(stageNode, 'Initial Targets') diff --git a/LowFrequencyTrading/TradingSystem.js b/LowFrequencyTrading/TradingSystem.js index 767973b32..b84db7f45 100644 --- a/LowFrequencyTrading/TradingSystem.js +++ b/LowFrequencyTrading/TradingSystem.js @@ -136,6 +136,12 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM included at the errors array. That means we need to do nothing here, just prevent the execution to be halted for not handling exceptions. */ + if (typeof err === 'string' || err instanceof String) { + logger.write(MODULE_NAME, '[ERROR] runExecution -> err = ' + err) + } + if (err.stack !== undefined) { + logger.write(MODULE_NAME, '[ERROR] runExecution -> err = ' + err.stack) + } } }