From ee0af1a21d00b8064655f2863f3b71e28795d21e Mon Sep 17 00:00:00 2001 From: olli Date: Fri, 14 Jun 2024 19:50:27 +0200 Subject: [PATCH] ccxt switch --- dabo/functions/get_asset.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dabo/functions/get_asset.sh b/dabo/functions/get_asset.sh index c91f335..59be79c 100644 --- a/dabo/functions/get_asset.sh +++ b/dabo/functions/get_asset.sh @@ -8,7 +8,11 @@ function get_asset { [ -f "${f_ASSET_HIST_FILE}" ] || echo "Date and Time,Price" >"${f_ASSET_HIST_FILE}" - local f_line="${f_timestamp},$(grep "^${f_ASSET}," CCXT_TICKERS | cut -d, -f2)" + #local f_line="${f_timestamp},$(grep "^${f_ASSET}," CCXT_TICKERS | cut -d, -f2)" + local f_price=$(grep "^${f_ASSET}," CCXT_TICKERS | cut -d, -f2) + # exponential number (9.881e-05) to normal + [[ $f_price =~ ^(-)?(\.)?[0-9]+(\.)?([0-9]+)?(e-[0-9]+)?$ ]] && printf -v f_price -- "%.10f" "$f_price" + local f_line="$f_timestamp,$f_price" echo "${f_line}" >>${f_ASSET_HIST_FILE} local f_linecount=0 @@ -31,7 +35,7 @@ function get_asset { return 0 fi - [ ${FULL_LOOP} == 0 ] && return 0 + #[ ${FULL_LOOP} == 0 ] && return 0 grep -q "^$(echo "${f_timestamp}" | cut -d: -f1,2)" "${f_ASSET_HIST_FILE}" || return 0 f_ASSET_HIST_FILE="asset-histories/${f_ASSET}.history.csv" #if find "${f_ASSET_HIST_FILE}" -mmin -${INTERVAL_MIN} | grep -q "${f_ASSET_HIST_FILE}" @@ -41,7 +45,7 @@ function get_asset { #fi # headline - #[ -s "${f_ASSET_HIST_FILE}" ] || echo "${csv_headline}" >"${f_ASSET_HIST_FILE}" + [ -s "${f_ASSET_HIST_FILE}" ] || echo "${csv_headline}" >"${f_ASSET_HIST_FILE}" if [ -s "${f_ASSET_HIST_FILE}" ] then sed -i -e 1c"$csv_headline" "${f_ASSET_HIST_FILE}"