diff --git a/dabo/functions/order_cancel.sh b/dabo/functions/order_cancel.sh index 09326e0..ca9118f 100644 --- a/dabo/functions/order_cancel.sh +++ b/dabo/functions/order_cancel.sh @@ -41,17 +41,55 @@ function order_cancel { g_echo_note "No orders for $f_symbol/$f_asset found" return 0 fi - - -# for f_order in "${f_get_orders_array[@]}" -# do -# get_order_line_vars "$f_order" -# if [[ $f_symbol = $f_order_symbol ]] -# then -# f_ccxt "print(${STOCK_EXCHANGE}.cancelAllOrders('$f_symbol'))" -# get_orders "$f_symbol" -# get_orders_array -# fi -# done - } + + +function order_cancel_all { + # Info for log + g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@" + + local f_order + + get_symbols_ticker + get_orders_array + + for f_order in "${f_get_orders_array[@]}" + do + get_order_line_vars "$f_order" + if [[ $f_symbol = $f_order_symbol ]] + then + f_ccxt "print(${STOCK_EXCHANGE}.cancelAllOrders('$f_symbol'))" + get_orders "$f_symbol" + get_orders_array + fi + done +} + +function order_cancel_id { + # Info for log + g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@" + + local f_symbol=$1 + local f_id=$2 + local f_order + + get_symbols_ticker + get_orders "$f_symbol" + get_orders_array + + local f_asset=${f_symbol//:$CURRENCY/} + f_asset=${f_asset//\//} + + if grep -q "$f_asset.*$f_id" values-orders + then + f_ccxt "print(${STOCK_EXCHANGE}.cancelOrder(id='${f_id}', symbol='${f_symbol}'))" + get_orders "$f_symbol" + get_orders_array + else + g_echo_note "No orders for $f_symbol/$f_asset with id $f_id found" + return 1 + fi +} + + +