From 4b05d1bb6a3f02657e2fd93d7e2055f0ef80ceae Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 31 Oct 2020 14:33:30 +0100 Subject: [PATCH] Bug Fixes --- LowFrequencyTrading/OrdersCalculations.js | 8 +++---- LowFrequencyTrading/OrdersSimulations.js | 4 ++-- LowFrequencyTrading/TradingSystem.js | 26 +++++------------------ 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/LowFrequencyTrading/OrdersCalculations.js b/LowFrequencyTrading/OrdersCalculations.js index f46332fd6..2728ecc24 100644 --- a/LowFrequencyTrading/OrdersCalculations.js +++ b/LowFrequencyTrading/OrdersCalculations.js @@ -63,7 +63,7 @@ exports.newOrdersCalculations = function newOrdersCalculations(bot, logger) { function recalculateActualSize() { /* - We will recalculate the Quoted Asset Actual Size. This will also give to it an initial value the first time we do this. + We will recalculate the Quoted Asset Actual Size. This will also give to it an initial value. In the next formula, we are unsing the rate of the order because we dont know yet the Actual Rate. This rate might be replaced afteerwards for the Actual Rate when this is calculated again once the Actual Rate is known. @@ -279,7 +279,7 @@ exports.newOrdersCalculations = function newOrdersCalculations(bot, logger) { need to calculate that by ourselves. */ tradingEngineOrder.orderQuotedAsset.sizeFilled.value = - tradingEngineOrder.orderQuotedAsset.sizeFilled.value * tradingEngineOrder.orderStatistics.percentageFilled.value / 100 + tradingEngineOrder.orderQuotedAsset.actualSize.value * tradingEngineOrder.orderStatistics.percentageFilled.value / 100 tradingEngineOrder.orderQuotedAsset.sizeFilled.value = global.PRECISE(tradingEngineOrder.orderQuotedAsset.sizeFilled.value, 10) } @@ -297,7 +297,7 @@ exports.newOrdersCalculations = function newOrdersCalculations(bot, logger) { /* In this case the Amount Received is in Base Asset. */ - tradingEngineOrder.orderBaseAsset.amountReceived.value.value = + tradingEngineOrder.orderBaseAsset.amountReceived.value = tradingEngineOrder.orderBaseAsset.sizeFilled.value - tradingEngineOrder.orderBaseAsset.feesPaid.value break @@ -306,7 +306,7 @@ exports.newOrdersCalculations = function newOrdersCalculations(bot, logger) { /* In this case the Amount Received is in Quoted Asset. */ - tradingEngineOrder.orderQuotedAsset.amountReceived.value.value = + tradingEngineOrder.orderQuotedAsset.amountReceived.value = tradingEngineOrder.orderQuotedAsset.sizeFilled.value - tradingEngineOrder.orderQuotedAsset.feesPaid.value break diff --git a/LowFrequencyTrading/OrdersSimulations.js b/LowFrequencyTrading/OrdersSimulations.js index 05e190bc5..5aafb1908 100644 --- a/LowFrequencyTrading/OrdersSimulations.js +++ b/LowFrequencyTrading/OrdersSimulations.js @@ -414,7 +414,7 @@ exports.newOrdersSimulations = function newOrdersSimulations(bot, logger) { /* In this case the Amount Received is in Base Asset. */ - tradingEngineOrder.orderBaseAsset.amountReceived.value.value = + tradingEngineOrder.orderBaseAsset.amountReceived.value = tradingEngineOrder.orderBaseAsset.sizeFilled.value - tradingEngineOrder.orderBaseAsset.feesPaid.value break @@ -423,7 +423,7 @@ exports.newOrdersSimulations = function newOrdersSimulations(bot, logger) { /* In this case the Amount Received is in Quoted Asset. */ - tradingEngineOrder.orderQuotedAsset.amountReceived.value.value = + tradingEngineOrder.orderQuotedAsset.amountReceived.value = tradingEngineOrder.orderQuotedAsset.sizeFilled.value - tradingEngineOrder.orderQuotedAsset.feesPaid.value break diff --git a/LowFrequencyTrading/TradingSystem.js b/LowFrequencyTrading/TradingSystem.js index 2e3af7ee3..ec82f80a7 100644 --- a/LowFrequencyTrading/TradingSystem.js +++ b/LowFrequencyTrading/TradingSystem.js @@ -17,7 +17,7 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM let tradingSystem let tradingEngine let sessionParameters - let dynamicIndicators + let dynamicIndicators const TRADING_STAGES_MODULE = require('./TradingStages.js') let tradingStagesModule = TRADING_STAGES_MODULE.newTradingStages(bot, logger, tradingEngineModule) @@ -131,8 +131,8 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM for (let i = 0; i < tradingSystem.dynamicIndicators.indicatorFunctions.length; i++) { let indicatorFunction = tradingSystem.dynamicIndicators.indicatorFunctions[i] - if (indicatorFunction.formula === undefined) { return} - if (indicatorFunction.config.codeName === undefined) { return} + if (indicatorFunction.formula === undefined) { return } + if (indicatorFunction.config.codeName === undefined) { return } dynamicIndicators[indicatorFunction.config.codeName] = tradingSystem.formulas.get(indicatorFunction.formula.id) } } @@ -257,15 +257,7 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM will not be considered an error. */ value = false - - if (code.indexOf('previous') > -1 && err.message.indexOf('of undefined') > -1 - ) { - /* - We are not going to set an error for the casess we are using previous and the error is that the indicator is undefined. - */ - } else { - error = err.message - } + error = err.message } tradingSystem.conditions.set(node.id, value) @@ -297,15 +289,7 @@ exports.newTradingSystem = function newTradingSystem(bot, logger, tradingEngineM will not be considered an error. */ value = 0 - - if (node.code.indexOf('previous') > -1 && err.message.indexOf('of undefined') > -1 - ) { - /* - We are not going to set an error for the casess we are using previous and the error is that the indicator is undefined. - */ - } else { - error = err.message - } + error = err.message } if (error !== undefined) {