assoziative array

This commit is contained in:
olli 2024-09-04 18:03:20 +02:00
parent 3e412615b9
commit 61c805ebfd

View File

@ -61,25 +61,62 @@ select(.status==\"open\") |
fi
done
cat CCXT_ORDERS_*${CURRENCY} >CCXT_ORDERS 2>/dev/null
return 0
get_orders_array
}
function get_orders_array {
g_array CCXT_ORDERS f_get_ordes_rarray
local f_order
# clear/create assoziative array o
unset o
declare -Ag o
# build array from lines in CCXT_ORDERS
g_array CCXT_ORDERS f_get_ordes_array
for f_order in ${f_get_ordes_array[@]}
do
get_order_line_vars "$f_order"
done
# write values to file
for i in "${!o[@]}"
do
echo "\${o[$i]}=${o[$i]}"
done | sort >values-orders.new
mv values-orders.new values-orders
}
function get_orders_line_vars {
function get_order_line_vars {
local f_order_line=$1
g_array $f_order_line f_order_array ,
f_order_symbol=${f_order_array[0]}
local f_asset=${f_order_symbol//:$CURRENCY/}
f_asset=${f_asset//\//}
o[${f_asset}_type]=${f_order_array[1]}
f_order_type=${f_order_array[1]}
o[${f_asset}_side]=${f_order_array[2]}
f_order_side=${f_order_array[2]}
o[${f_asset}_entry_price]=${f_order_array[3]}
f_order_entry_price=${f_order_array[3]}
o[${f_asset}_amount]=${f_order_array[4]}
f_order_amount=${f_order_array[4]}
o[${f_asset}_id]=${f_order_array[5]}
f_order_id=${f_order_array[5]}
o[${f_asset}_stoplossprice]=${f_order_array[6]}
f_order_stoplossprice=${f_order_array[6]}
o[${f_asset}_takeprofitprice]=${f_order_array[7]}
f_order_takeprofitprice=${f_order_array[7]}
}