From 69ef7c217fd5a94b94fcf4875ad0e4e702ba5d5c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 2 May 2018 20:48:00 +0200 Subject: [PATCH] Rounding BUG corrected --- .vs/AACloud/v15/.suo | Bin 100864 -> 103936 bytes Assistant.js | 21 +++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.vs/AACloud/v15/.suo b/.vs/AACloud/v15/.suo index 8e883487b15302f051b255ea22255e161d9498f7..c975857f2d68d341ea57775429c2d836a3178485 100644 GIT binary patch delta 2270 zcmciCeNYs27zgls_HK_mJ>51OH-oFBb2g{RWO@wPUzoz#(m-BguA^tzZQ-P+(3}B@ zFb;~q2I=rBH(PS)O(r>>_V93d1ii+O$fh%8 zjY7m`#v=Owo`6yCD2Reo!vuH-WLO8m+LAGpRa+8Ivv`wz5zREdx6gOk$&GswMBhgY zH5n@t=8$DjpEl#y5$7F7>)gqtK0KX|o5#~9=ro(`x7XCS=fHL{nJjn|mvL($Nx`hv z(MD_9WYXt3^?*fRY}40B`ZB9plSUektr^3`10Hx$LHAuC>RAu(f*;-k9acjCL?CFqFQ~UP#)|bdPBmkC&$jQrv#y4;(jrRGmX_iKcuE|`OIw^~X>^=XUHgVbt@qkQ zRSNDJt-gT_r7lAHVM*U51%ri>QTWyo((<08WFuL>W~bFWykWI0c6WrgH!RHDi!2Py za14&aXCPMkc{H{negQXY7j&xig%eP?bk&!4(yL$fq!_Q~iNde9MYH`Es*zP)WcHuW z;a@ttqV1<6D(8IT;*o7}nk${Q5V5;0oqL*RjXK;uB&YINySpjhkyo@6=`@KW z7vi)dK1vvL0xK8)&qS=?l(zUjyS{hV&fNcLiM#RnizSMfdG96m>w4doSir%{Q+e0r za?bBaU{9yQzVlYYb15v7Piu~)eBRcQ!TuKIU-7wz7|lQDN@|zFv$_?-(-kIl7*76g z`1XE~^gkpmC6Okw(xs@^JnEIo;7=an@bzqN+~C%79W+>5KakRFTgaP}ji0^Y$z=S$w1Y2p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/Assistant.js +++ b/Assistant.js @@ -611,12 +611,17 @@ } + sumAssetB = Number(sumAssetB.toFixed(8)); + if ( position.amountB !== sumAssetB ) { + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> position.amountB = " + position.amountB); + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> sumAssetB = " + sumAssetB); + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> Cannot be confirmed that the order was executed. It must be manually cancelled by the user or cancelled by the exchange itself."); logger.write("[HINT] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> If the process was abruptally cancelled and then restarted, it is possible that now is not sincronized with the exchange."); - logger.write("[HINT] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> In any case, to continue, you must delete the Status Report file so as to start over. Also, you must manually delete the orders at the exchange."); + logger.write("[HINT] ordersExecutionCheck -> loopBody -> confirmOrderWasExecuted -> In any case, to continue, you must manually delete the orders at the exchange."); callBack(global.DEFAULT_FAIL_RESPONSE); return; } @@ -676,6 +681,10 @@ sumAssetA = sumAssetA + pTrades[k].amountA; sumAssetB = sumAssetB + pTrades[k].amountB; + /* We add the fees */ + + sumAssetA = sumAssetA - Number(pTrades[k].fee); + } /* To this we add the current position amounts. */ @@ -683,14 +692,18 @@ sumAssetA = sumAssetA + exchangePosition.amountA; sumAssetB = sumAssetB + exchangePosition.amountB; - /* And finally we add the fees */ - - sumAssetA = sumAssetA + exchangePosition.fee; + sumAssetA = Number(sumAssetA.toFixed(8)); + sumAssetB = Number(sumAssetB.toFixed(8)); if ( position.amountA !== sumAssetA || position.amountB !== sumAssetB ) { + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> position.amountA = " + position.amountA); + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> sumAssetA = " + sumAssetA); + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> position.amountB = " + position.amountB); + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> sumAssetB = " + sumAssetB); + logger.write("[ERROR] ordersExecutionCheck -> loopBody -> confirmOrderWasPartiallyExecuted -> Cannot be confirmed that a partially execution was done well."); callBack(global.DEFAULT_FAIL_RESPONSE); return;