more pure bash to speed up things
This commit is contained in:
parent
712fe8a1ac
commit
11d7169c88
@ -7,13 +7,19 @@ function get_vars_from_csv {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "${f_last_lines}" ]
|
||||||
|
then
|
||||||
|
mapfile -t f_last_lines <<< $(tail -n4 "${f_ASSET_HIST_FILE}")
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${f_market_performance}" ]
|
if [ -z "${f_market_performance}" ]
|
||||||
then
|
then
|
||||||
f_market_performance="-50"
|
f_market_performance="-50"
|
||||||
fi
|
fi
|
||||||
f_all_vars="f_market_performance=${f_market_performance}"
|
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}")
|
readarray -d "," -t f_last_line_array < <(echo "0,${f_last_line}")
|
||||||
|
|
||||||
f_asset=$(basename ${f_ASSET_HIST_FILE} | cut -d\. -f1)
|
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
|
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_prices=$(tail -n4 "${f_ASSET_HIST_FILE}" | cut -d, -f2)
|
||||||
f_last_4_price=$(echo ${f_last_4_prices} | head -n1)
|
#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_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
|
# if printf '%s\n' ${f_last_4_prices} | sort -n -C
|
||||||
then
|
# then
|
||||||
f_price_trend="constantly growing,${f_last_4_prices_change}"
|
# f_price_trend="constantly growing,${f_last_4_prices_change}"
|
||||||
elif printf '%s\n' ${f_last_4_prices} | sort -n -r -C
|
# elif printf '%s\n' ${f_last_4_prices} | sort -n -r -C
|
||||||
then
|
# then
|
||||||
f_price_trend="constantly falling,${f_last_4_prices_change}"
|
# f_price_trend="constantly falling,${f_last_4_prices_change}"
|
||||||
elif 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}"
|
||||||
|
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
|
elif g_num_is_lower ${f_last_4_prices_change} 0
|
||||||
then
|
then
|
||||||
f_price_trend="falling,${f_last_4_prices_change}"
|
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
|
else
|
||||||
f_price_trend="constant,${f_last_4_prices_change}"
|
f_price_trend="constant,${f_last_4_prices_change}"
|
||||||
fi
|
fi
|
||||||
@ -103,6 +118,8 @@ f_macd_histogram_signal=${f_macd_histogram_signal}"
|
|||||||
# Coingecko price
|
# Coingecko price
|
||||||
get_var_from_line coingecko_price 40
|
get_var_from_line coingecko_price 40
|
||||||
|
|
||||||
|
unset f_last_lines
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_var_from_line {
|
function get_var_from_line {
|
||||||
|
Loading…
Reference in New Issue
Block a user