more pure bash to speed up things
This commit is contained in:
parent
712fe8a1ac
commit
11d7169c88
@ -6,14 +6,20 @@ function get_vars_from_csv {
|
||||
g_echo_warn "${f_ASSET_HIST_FILE} does not exist or is empty"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "${f_last_lines}" ]
|
||||
then
|
||||
mapfile -t f_last_lines <<< $(tail -n4 "${f_ASSET_HIST_FILE}")
|
||||
fi
|
||||
|
||||
if [ -z "${f_market_performance}" ]
|
||||
then
|
||||
f_market_performance="-50"
|
||||
fi
|
||||
f_all_vars="f_market_performance=${f_market_performance}"
|
||||
|
||||
f_last_line="$(tail -n1 "${f_ASSET_HIST_FILE}"),${f_market_performance}"
|
||||
#f_last_line="$(tail -n1 "${f_ASSET_HIST_FILE}"),${f_market_performance}"
|
||||
f_last_line="${f_last_lines[3]}"
|
||||
readarray -d "," -t f_last_line_array < <(echo "0,${f_last_line}")
|
||||
|
||||
f_asset=$(basename ${f_ASSET_HIST_FILE} | cut -d\. -f1)
|
||||
@ -24,22 +30,31 @@ function get_vars_from_csv {
|
||||
get_var_from_line price_change 3
|
||||
|
||||
# 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=$(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_last_lines[0]} ${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}"
|
||||
elif g_num_is_higher ${f_last_4_prices_change} 0
|
||||
# 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
|
||||
then
|
||||
f_price_trend="growing,${f_last_4_prices_change}"
|
||||
if g_num_is_higher ${f_last_lines[1]} ${f_last_lines[0]} && g_num_is_higher ${f_last_lines[2]} ${f_last_lines[1]} && g_num_is_higher ${f_last_lines[3]} ${f_last_lines[2]}
|
||||
then
|
||||
f_price_trend="constantly growing,${f_last_4_prices_change}"
|
||||
fi
|
||||
elif g_num_is_lower ${f_last_4_prices_change} 0
|
||||
then
|
||||
f_price_trend="falling,${f_last_4_prices_change}"
|
||||
if g_num_is_lower ${f_last_lines[1]} ${f_last_lines[0]} && g_num_is_lower ${f_last_lines[2]} ${f_last_lines[1]} && g_num_is_lower ${f_last_lines[3]} ${f_last_lines[2]}
|
||||
then
|
||||
f_price_trend="constantly falling,${f_last_4_prices_change}"
|
||||
fi
|
||||
else
|
||||
f_price_trend="constant,${f_last_4_prices_change}"
|
||||
fi
|
||||
@ -103,6 +118,8 @@ f_macd_histogram_signal=${f_macd_histogram_signal}"
|
||||
# Coingecko price
|
||||
get_var_from_line coingecko_price 40
|
||||
|
||||
unset f_last_lines
|
||||
|
||||
}
|
||||
|
||||
function get_var_from_line {
|
||||
|
Loading…
Reference in New Issue
Block a user