From 724d7b46333cf59bbe21a4a6df8d5d958cef2da1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 14 Mar 2018 17:03:04 +0100 Subject: [PATCH] findPreviousContent() upgraded to Alpha --- .vs/AAOlivia-Indicator-Bot/v15/.suo | Bin 23040 -> 22016 bytes Multi-Period-Market/Interval.js | 90 ++++++++++++++-------------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/.vs/AAOlivia-Indicator-Bot/v15/.suo b/.vs/AAOlivia-Indicator-Bot/v15/.suo index 345922152152404b106c48b0de6545c181719006..8eb844d70421674f4adb2f73384bb3c6faed5847 100644 GIT binary patch delta 188 zcmZqJ!q~8eae{#Y0}Kc-Fo*%!j6nSF|Ns9WVGw&`;CjZ%{~2>xFQnM+T|2pu>C$9p z_6A-?pmGMFGBB9TD6g{l3v&e%>xbRy+tzL_WDD1te1fNDvx{Lp6E9d98&o+&DgOmV z9%i5j6N;#yKhxyHBC(qnh+GnxJj2Ov^8w#l7AAYf&GtcFjI16&*EDSI3oc>;0H0t( AyZ`_I delta 281 zcmZoz!`QHeae{#Y69W_oFfgzHnT$aE@Bjb*AW>!@-Wa%^aq@r0T-Ju(4L4RzE@Zki z`7o2= findPreviousContent -> loopBody -> getCandles -> fileName = " + fileName); } + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getCandles -> filePath = " + filePath); } + oliviaAzureFileStorage.getTextFile(filePath, fileName, onFileReceived, true); - function onFileReceived(text) { + function onFileReceived(err, text) { if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> Entering function."); } if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> text = " + text); } let candlesFile; - try { + if (err.result === global.CUSTOM_OK_RESPONSE.result) { + try { + candlesFile = JSON.parse(text); - candlesFile = JSON.parse(text); + previousCandles = candlesFile; - previousCandles = candlesFile; + getVolumes(); - getVolumes(); - - } catch (err) { - - const logText = "[ERR] 'findPreviousContent' - Empty or corrupt candle file found at " + filePath + " for market " + market.assetA + '_' + market.assetB + " . Skipping this Market. "; - logger.write(logText); - - + } catch (err) { + logger.write("[ERROR] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> err = " + err.message); + logger.write("[ERROR] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); + callBackFunction(global.DEFAULT_RETRY_RESPONSE); + } + } else { + logger.write("[ERROR] start -> findPreviousContent -> loopBody -> getCandles -> onFileReceived -> err = " + err.message); + callBackFunction(err); } } } @@ -322,32 +326,37 @@ Read the candles and volumes from Bruce and produce a single Index File for Mark let filePath = EXCHANGE_NAME + "/Output/" + VOLUMES_FOLDER_NAME + "/" + bot.process + "/" + folderName; + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getVolumes -> fileName = " + fileName); } + if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getVolumes -> filePath = " + filePath); } + oliviaAzureFileStorage.getTextFile(filePath, fileName, onFileReceived, true); - function onFileReceived(text) { + function onFileReceived(err, text) { if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> Entering function."); } if (FULL_LOG === true) { logger.write("[INFO] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> text = " + text); } let volumesFile; - try { + if (err.result === global.CUSTOM_OK_RESPONSE.result) { + try { + volumesFile = JSON.parse(text); - volumesFile = JSON.parse(text); + previousVolumes = volumesFile; - previousVolumes = volumesFile; + allPreviousCandles.push(previousCandles); + allPreviousVolumes.push(previousVolumes); - allPreviousCandles.push(previousCandles); - allPreviousVolumes.push(previousVolumes); + controlLoop(); - controlLoop(); - - } catch (err) { - - const logText = "[ERR] 'findPreviousContent' - Empty or corrupt volume file found at " + filePath + " for market " + market.assetA + '_' + market.assetB + " . Skipping this Market. "; - logger.write(logText); - - + } catch (err) { + logger.write("[ERROR] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> err = " + err.message); + logger.write("[ERROR] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> Asuming this is a temporary situation. Requesting a Retry."); + callBackFunction(global.DEFAULT_RETRY_RESPONSE); + } + } else { + logger.write("[ERROR] start -> findPreviousContent -> loopBody -> getVolumes -> onFileReceived -> err = " + err.message); + callBackFunction(err); } } } @@ -372,11 +381,9 @@ Read the candles and volumes from Bruce and produce a single Index File for Mark } } catch (err) { - const logText = "[ERROR] 'findPreviousContent' - ERROR : " + err.message; - logger.write(logText); - + logger.write("[ERROR] start -> findPreviousContent -> err = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); } - } function buildCandles(allPreviousCandles, allPreviousVolumes) { @@ -738,13 +745,10 @@ Read the candles and volumes from Bruce and produce a single Index File for Mark } } } - catch (err) { - const logText = "[ERROR] 'buildCandles' - ERROR : " + err.message; - logger.write(logText); - + logger.write("[ERROR] start -> buildCandles -> err = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); } - } function writeFiles(candles, volumes, folderName, callBack) { @@ -853,12 +857,10 @@ Read the candles and volumes from Bruce and produce a single Index File for Mark } } } - } - + } catch (err) { - const logText = "[ERROR] 'writeFiles' - ERROR : " + err.message; - logger.write(logText); - + logger.write("[ERROR] start -> writeFiles -> err = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); } } @@ -874,11 +876,9 @@ Read the candles and volumes from Bruce and produce a single Index File for Mark } catch (err) { - const logText = "[ERROR] 'writeStatusReport' - ERROR : " + err.message; - logger.write(logText); - + logger.write("[ERROR] start -> writeStatusReport -> err = " + err.message); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); } - } }