no subshells for calculation

This commit is contained in:
2023-11-26 17:18:01 +01:00
parent eb520626cb
commit db7ba20416
13 changed files with 63 additions and 61 deletions

View File

@@ -20,28 +20,6 @@ function get_rsi_indicator {
return 0
fi
# for f_price in $(tail -n${f_period} "${f_hist_file}" | cut -d"," -f2)
# do
# # not for the first line because a comparative value is missing
# if [ -z "${f_last_price}" ]
# then
# f_last_price=${f_price}
# continue
# fi
#
# # calculate each change
# local f_price_change=$(g_percentage-diff ${f_last_price} ${f_price})
# f_last_price=${f_price}
#
# # add positive/negative changes
# if echo "${f_price_change}" | grep -q '^-'
# then
# f_negative_sum=$(echo "${f_negative_sum}+${f_price_change}" | bc -l)
# else
# f_positive_sum=$(echo "${f_positive_sum}+${f_price_change}" | bc -l)
# fi
# done
f_positive_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f3 | grep "^[0-9]" | awk "{ SUM += \$1} END { printf(\"%10.10f\", SUM/${f_period}) }")
f_negative_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d"," -f3 | grep "^-[0-9]" | awk "{ SUM += \$1} END { printf(\"%10.10f\", SUM/${f_period}) }")