more pure bash to speed up things

This commit is contained in:
olli 2023-11-12 12:55:50 +01:00
parent c68a41930f
commit 5f5c19eea9

View File

@ -27,7 +27,6 @@ function get_vars_from_csv {
fi fi
# create array of last line fields # create array of last line fields
#f_last_line="$(tail -n1 "${f_ASSET_HIST_FILE}"),${f_market_performance}"
f_last_line="${f_last_lines_array[3]},${f_market_performance}" f_last_line="${f_last_lines_array[3]},${f_market_performance}"
readarray -d "," -t f_last_line_array < <(echo "0,${f_last_line}") readarray -d "," -t f_last_line_array < <(echo "0,${f_last_line}")
readarray -d "," -t f_2_last_line_array < <(echo "0,${f_last_lines_array[2]}") readarray -d "," -t f_2_last_line_array < <(echo "0,${f_last_lines_array[2]}")
@ -37,7 +36,6 @@ function get_vars_from_csv {
# remove f_last_lines_array # remove f_last_lines_array
unset f_last_lines_array unset f_last_lines_array
#f_asset=$(basename ${f_ASSET_HIST_FILE} | cut -d\. -f1)
# bash-only basename # bash-only basename
f_asset="${f_ASSET_HIST_FILE##*/}" f_asset="${f_ASSET_HIST_FILE##*/}"
@ -47,17 +45,8 @@ function get_vars_from_csv {
get_var_from_line price_change 3 get_var_from_line price_change 3
# Check for price trend last 4 iterations # Check for price trend last 4 iterations
#f_last_4_prices=$(tail -n4 "${f_ASSET_HIST_FILE}" | cut -d, -f2)
#f_last_4_price=$(echo ${f_last_4_prices} | head -n1)
#f_last_4_prices_change=$(g_percentage-diff ${f_last_4_price} ${f_price})
f_last_4_prices_change=$(g_percentage-diff ${f_4_last_line_array[2]} ${f_price}) f_last_4_prices_change=$(g_percentage-diff ${f_4_last_line_array[2]} ${f_price})
# if printf '%s\n' ${f_last_4_prices} | sort -n -C
# then
# f_price_trend="constantly growing,${f_last_4_prices_change}"
# elif printf '%s\n' ${f_last_4_prices} | sort -n -r -C
# then
# f_price_trend="constantly falling,${f_last_4_prices_change}"
if g_num_is_higher ${f_last_4_prices_change} 0 if g_num_is_higher ${f_last_4_prices_change} 0
then then
f_price_trend="growing,${f_last_4_prices_change}" f_price_trend="growing,${f_last_4_prices_change}"
@ -85,10 +74,8 @@ f_price_trend=${f_price_trend}"
# MACD # MACD
get_var_from_line macd_histogram 8 get_var_from_line macd_histogram 8
get_var_from_line macd_signal_relation 9 get_var_from_line macd_signal_relation 9
#f_macd_histogram_relation=$(echo "${f_macd_signal_relation}" | cut -d\| -f1)
f_macd_histogram_relation="${f_macd_signal_relation%|*}" f_macd_histogram_relation="${f_macd_signal_relation%|*}"
[ -z "$f_macd_histogram_relation" ] && return 1 [ -z "$f_macd_histogram_relation" ] && return 1
#f_macd_histogram_signal=$(echo "${f_macd_signal_relation}" | cut -d\| -f2)
f_macd_histogram_signal="${f_macd_signal_relation#*|}" f_macd_histogram_signal="${f_macd_signal_relation#*|}"
f_all_vars="${f_all_vars} f_all_vars="${f_all_vars}
f_macd_histogram_relation=${f_macd_histogram_relation} f_macd_histogram_relation=${f_macd_histogram_relation}