fix levels array

This commit is contained in:
olli 2024-08-27 20:47:24 +02:00
parent 492d9babfa
commit d9a82b2844

View File

@ -69,13 +69,14 @@ function get_values {
if [ -s "$f_levelsfile" ] if [ -s "$f_levelsfile" ]
then then
# get levels # get levels
g_array "$f_levelsfile" f_levels " " read -r -a f_levels <"$f_levelsfile"
v[${f_asset}_levels_$f_time]="${f_levels[*]}" v[${f_asset}_levels_$f_time]="${f_levels[*]}"
# add current price and sort # add current price and sort
f_levels+=("${v[${f_asset}_price]}") f_levels+=("${v[${f_asset}_price]}")
oldIFS="$IFS"
IFS=$'\n' f_levels_sorted=($(sort -n <<<"${f_levels[*]}")) IFS=$'\n' f_levels_sorted=($(sort -n <<<"${f_levels[*]}"))
unset IFS IFS="$oldIFS"
# find current price and +- one for upper lower price # find current price and +- one for upper lower price
for ((i=0; i<${#f_levels_sorted[@]}; i++)); do for ((i=0; i<${#f_levels_sorted[@]}; i++)); do