From 5e427ffde3f97e9fc31afda0d49a3191cfd3f154 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 26 Jul 2018 09:43:26 +0200 Subject: [PATCH] Exchange Presicion constant added --- Assistant.js | 6 ++++-- ExchangeAPI.js | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assistant.js b/Assistant.js index 32b181745..9ee69d79a 100644 --- a/Assistant.js +++ b/Assistant.js @@ -557,7 +557,7 @@ if (thisPosition.id === pPositionId) { - let feeRate = 0.0025; // Default fee + let feeRate = 0.002; // Default fee if (Math.random(1) < 0.5) feeRate = 0.0015; // Some times we will pay less fee @@ -737,7 +737,9 @@ sumAssetA = thisObject.truncDecimals(sumAssetA); sumAssetB = thisObject.truncDecimals(sumAssetB); - if (Math.abs(thisObject.truncDecimals(position.amountA) - sumAssetA) > 0.00000001 || Math.abs(position.amountB - sumAssetB) > 0.00000001) { + const EXCHANGE_PRECISION = 0.00001; // This value was determined empirically. We noticed that the sume of the trades plus the remaining order at the exchange didn't exatly matched the positions we keep at the execution context, and the only explanation found was that the exchange presicion was not big enough to make it match. So to avoid unnecesary warnings, we created this constant that filters out this situation. + + if (Math.abs(thisObject.truncDecimals(position.amountA) - sumAssetA) > EXCHANGE_PRECISION || Math.abs(position.amountB - sumAssetB) > EXCHANGE_PRECISION) { logger.write(MODULE_NAME, "[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> position.amountA = " + position.amountA); logger.write(MODULE_NAME, "[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> sumAssetA = " + sumAssetA); diff --git a/ExchangeAPI.js b/ExchangeAPI.js index d3ea64b8a..744c7ac65 100644 --- a/ExchangeAPI.js +++ b/ExchangeAPI.js @@ -165,6 +165,8 @@ trades.push(trade); } + if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write(MODULE_NAME, "[INFO] getExecutedTrades -> onExchangeCallReturned -> trades = " + JSON.stringify(trades)); } + callBackFunction(global.DEFAULT_OK_RESPONSE, trades); } }