From 40a045298d1658708a9e094f4f3efb2e8fb935c4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 27 Jun 2019 14:04:22 +0200 Subject: [PATCH] Bug Fixed: if (strategyStage === 'Trigger Stage' || strategyStage === 'No Stage') { --- Commons.js | 96 +++++++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/Commons.js b/Commons.js index 08685cd63..630de1ccf 100644 --- a/Commons.js +++ b/Commons.js @@ -400,7 +400,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { /* We set some variables that would be nice if they have a value before the formulas are calculated. */ - if (strategyStage === 'Trigger Stage') { + if (strategyStage === 'Trigger Stage' || strategyStage === 'No Stage') { positionRate = candle.close; @@ -1388,56 +1388,56 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { } orderRecord = createMessage( - messageId, - MESSAGE_ENTITY.SimulationEngine, - MESSAGE_ENTITY.SimulationExecutor, - messageType, - (new Date()).valueOf(), - orderId.toString(), - ORDER_CREATOR.SimulationEngine, - (new Date()).valueOf(), - ORDER_OWNER.User, - global.EXCHANGE_NAME, - "BTC_USDT", - 0, - ORDER_TYPE.Limit, - marketRate, - stopLoss, - takeProfit, - ORDER_DIRECTION.Sell, - -1, - ORDER_STATUS.Signaled, - 0, - "") + messageId, + MESSAGE_ENTITY.SimulationEngine, + MESSAGE_ENTITY.SimulationExecutor, + messageType, + (new Date()).valueOf(), + orderId.toString(), + ORDER_CREATOR.SimulationEngine, + (new Date()).valueOf(), + ORDER_OWNER.User, + global.EXCHANGE_NAME, + "BTC_USDT", + 0, + ORDER_TYPE.Limit, + marketRate, + stopLoss, + takeProfit, + ORDER_DIRECTION.Sell, + -1, + ORDER_STATUS.Signaled, + 0, + "") } else { orderRecord = createMessage( - messageId, - MESSAGE_ENTITY.SimulationEngine, - MESSAGE_ENTITY.SimulationExecutor, - MESSAGE_TYPE.HeartBeat, - (new Date()).valueOf(), - "", - "", - 0, - "", - "", - "", - 0, - "", - 0, - 0, - 0, - "", - 0, - "", - 0, - "") + messageId, + MESSAGE_ENTITY.SimulationEngine, + MESSAGE_ENTITY.SimulationExecutor, + MESSAGE_TYPE.HeartBeat, + (new Date()).valueOf(), + "", + "", + 0, + "", + "", + "", + 0, + "", + 0, + 0, + 0, + "", + 0, + "", + 0, + "") } - let strategyStageNumber + let strategyStageNumber switch (strategyStage) { case 'No Stage': { strategyStageNumber = 0 @@ -1461,6 +1461,14 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) { } } + if (balanceAssetA === Infinity) { + balanceAssetA = Number.MAX_SAFE_INTEGER + } + + if (balanceAssetB === Infinity) { + balanceAssetB = Number.MAX_SAFE_INTEGER + } + simulationRecord = { begin: candle.begin, end: candle.end,