From 61c805ebfd7da47abf1797909edbc782106c9b05 Mon Sep 17 00:00:00 2001 From: olli Date: Wed, 4 Sep 2024 18:03:20 +0200 Subject: [PATCH] assoziative array --- dabo/functions/get_orders.sh | 45 ++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/dabo/functions/get_orders.sh b/dabo/functions/get_orders.sh index 49de0a8..01015b9 100644 --- a/dabo/functions/get_orders.sh +++ b/dabo/functions/get_orders.sh @@ -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]} + }