From a45b4e5f511b1ea9b04ba85768b5213c2ef0ea28 Mon Sep 17 00:00:00 2001 From: olli Date: Tue, 24 Sep 2024 16:43:38 +0200 Subject: [PATCH] multiple orders in array --- dabo/functions/get_orders.sh | 50 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/dabo/functions/get_orders.sh b/dabo/functions/get_orders.sh index 1fba19a..be0ed97 100644 --- a/dabo/functions/get_orders.sh +++ b/dabo/functions/get_orders.sh @@ -90,36 +90,40 @@ function get_orders_array { 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]} - - o[${f_asset}_stopprice]=${f_order_array[8]} - f_order_stopprice=${f_order_array[8]} + local f_order_type=${f_order_array[1]} + local f_order_side=${f_order_array[2]} + local f_type + if [[ $f_order_type = limit ]] + then + [[ $f_order_type = buy ]] && f_type="open_long" + [[ $f_order_type = sell ]] && f_type="open_short" + fi + if [[ $f_order_type = Stop ]] + then + [[ $f_order_type = buy ]] && f_type="sl_close_short" + [[ $f_order_type = sell ]] && f_type="sl_close_long" + fi + if [[ $f_order_type = MarketIfTouched ]] + then + [[ $f_order_type = buy ]] && f_type="tp_close_short" + [[ $f_order_type = sell ]] && f_type="tp_close_long" + fi + o[${f_asset}_${f_type}_type]=${f_order_array[1]} + o[${f_asset}_${f_type}_side]=${f_order_array[2]} + o[${f_asset}_${f_type}_entry_price]=${f_order_array[3]} + o[${f_asset}_${f_type}_amount]=${f_order_array[4]} + o[${f_asset}_${f_type}_id]=${f_order_array[5]} + o[${f_asset}_${f_type}_stoplossprice]=${f_order_array[6]} + o[${f_asset}_${f_type}_takeprofitprice]=${f_order_array[7]} + o[${f_asset}_${f_type}_stopprice]=${f_order_array[8]} }