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}"