139 lines
4.4 KiB
Bash
139 lines
4.4 KiB
Bash
function get_vars_from_csv {
|
|
|
|
f_ASSET_HIST_FILE="$1"
|
|
if ! [ -s "${f_ASSET_HIST_FILE}" ]
|
|
then
|
|
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="${f_last_lines[3]}"
|
|
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[2]}")
|
|
readarray -d "," -t f_3_last_line_array < <(echo "0,${f_last_lines[1]}")
|
|
readarray -d "," -t f_4_last_line_array < <(echo "0,${f_last_lines[0]}")
|
|
|
|
f_asset=$(basename ${f_ASSET_HIST_FILE} | cut -d\. -f1)
|
|
|
|
# basics
|
|
get_var_from_line date 1
|
|
get_var_from_line price 2
|
|
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_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
|
|
then
|
|
f_price_trend="growing,${f_last_4_prices_change}"
|
|
if g_num_is_higher ${f_3_last_line_array[2]} ${f_4_last_line_array[2]} && g_num_is_higher ${f_2_last_line_array[2]} ${f_3_last_line_array[2]} && g_num_is_higher ${f_price} ${f_2_last_line_array[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_3_last_line_array[2]} ${f_4_last_line_array[2]} && g_num_is_lower ${f_2_last_line_array[2]} ${f_3_last_line_array[2]} && g_num_is_lower ${f_price} ${f_2_last_line_array[2]}
|
|
#then
|
|
# f_price_trend="constantly falling,${f_last_4_prices_change}"
|
|
#fi
|
|
else
|
|
f_price_trend="constant,${f_last_4_prices_change}"
|
|
fi
|
|
f_all_vars="$f_all_vars
|
|
f_price_trend=${f_price_trend}"
|
|
|
|
# MACD EMA
|
|
get_var_from_line ema12 4
|
|
get_var_from_line ema26 5
|
|
|
|
# MACD
|
|
get_var_from_line macd_histogram 8
|
|
get_var_from_line macd_signal_relation 9
|
|
f_macd_histogram_relation=$(echo "${f_macd_signal_relation}" | cut -d\| -f1)
|
|
[ -z "$f_macd_histogram_relation" ] && return 1
|
|
f_macd_histogram_signal=$(echo "${f_macd_signal_relation}" | cut -d\| -f2)
|
|
f_all_vars="${f_all_vars}
|
|
f_macd_histogram_relation=${f_macd_histogram_relation}
|
|
f_macd_histogram_signal=${f_macd_histogram_signal}"
|
|
|
|
# rsi
|
|
get_var_from_line rsi5 10
|
|
get_var_from_line rsi14 11
|
|
get_var_from_line rsi21 12
|
|
get_var_from_line rsi720 13
|
|
get_var_from_line rsi60 14
|
|
get_var_from_line rsi120 15
|
|
get_var_from_line rsi240 16
|
|
get_var_from_line rsi420 17
|
|
|
|
# price changes
|
|
get_var_from_line price_change_1_day 18
|
|
get_var_from_line price_change_7_day 19
|
|
get_var_from_line price_change_14_day 20
|
|
get_var_from_line price_change_30_day 21
|
|
get_var_from_line price_change_1_year 22
|
|
|
|
# marketcap
|
|
get_var_from_line marketcap_change_1_day 23
|
|
|
|
# range and fibonacci
|
|
get_var_from_line range_date 24
|
|
get_var_from_line lowest_in_range 25
|
|
get_var_from_line highest_in_range 26
|
|
get_var_from_line pivot_point 27
|
|
get_var_from_line support1 28
|
|
get_var_from_line resist1 29
|
|
get_var_from_line golden_pocket_support 30
|
|
get_var_from_line golden_pocket_resist 31
|
|
get_var_from_line golden_pocket65_support 32
|
|
get_var_from_line golden_pocket65_resist 33
|
|
get_var_from_line support3 34
|
|
get_var_from_line resist3 35
|
|
|
|
# EMAs
|
|
get_var_from_line ema50 36
|
|
get_var_from_line ema100 37
|
|
get_var_from_line ema200 38
|
|
get_var_from_line ema800 39
|
|
|
|
# Coingecko price
|
|
get_var_from_line coingecko_price 40
|
|
|
|
unset f_last_lines
|
|
|
|
}
|
|
|
|
function get_var_from_line {
|
|
if [ -z "${f_last_line_array[$2]}" ]
|
|
then
|
|
g_echo_note "${f_ASSET_HIST_FILE}: Didn't get $1 in position $2"
|
|
return 1
|
|
fi
|
|
declare -g f_$1="$(echo ${f_last_line_array[$2]})"
|
|
f_all_vars="$f_all_vars
|
|
f_$1=$(echo ${f_last_line_array[$2]})"
|
|
}
|
|
|