From 76f556b1ad0b09daac22c6dde5f16b33c6cf55d3 Mon Sep 17 00:00:00 2001 From: olli Date: Mon, 16 Dec 2024 17:38:39 +0100 Subject: [PATCH] fixes tp/sl --- dabo/functions/order.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dabo/functions/order.sh b/dabo/functions/order.sh index 0f5b61d..39e21e8 100644 --- a/dabo/functions/order.sh +++ b/dabo/functions/order.sh @@ -94,7 +94,7 @@ function order { # check for swap/margin trades - if [ -n "$LEVERAGE" ] && [[ $f_price != stoploss ]] && [[ $f_price != takeprofit ]] + if [ -n "$LEVERAGE" ] then # do some margin things @@ -110,10 +110,13 @@ function order { # define margin mode isolated/cross #[[ $f_type =~ limit|market ]] && f_params="${f_params}'marginMode': '$MARGIN_MODE', " - + # calculate amount with leverage - g_calc "${f_amount}*${LEVERAGE}" - f_amount=$g_calc_result + if [[ $f_price != stoploss ]] && [[ $f_price != takeprofit ]] + then + g_calc "${f_amount}*${LEVERAGE}" + f_amount=$g_calc_result + fi else # short/sell not possible in spot market [[ $f_side =~ ^sell$ ]] || return 1 @@ -148,7 +151,8 @@ function order { elif [[ $f_type = "stoploss" ]] then f_type="market" - f_params="${f_params}'reduceOnly': True, 'triggerPrice': $f_stoploss, 'triggerDirection': 'down', 'type': '$f_type'" + f_price=$f_stoploss + f_params="${f_params}'reduceOnly': True, 'triggerPrice': $f_stoploss, 'triggerDirection': 'down'" fi fi if [ -n "$f_takeprofit" ] @@ -174,7 +178,8 @@ function order { if [[ $f_type = "takeprofit" ]] then f_type="limit" - f_params="${f_params}'reduceOnly': True, 'triggerPrice': $f_takeprofit, 'triggerDirection': 'up', 'type': '$f_type'" + f_price=$f_takeprofit + f_params="${f_params}'reduceOnly': True, 'triggerPrice': $f_takeprofit, 'triggerDirection': 'up'" fi fi @@ -196,7 +201,7 @@ function order { [[ $f_type = market ]] && local f_order="symbol='${f_symbol}', type='$f_type', amount=${f_amount}, side='${f_side}', ${f_params}" # takeprofit/stoploss only - [[ $f_price = None ]] && local f_order="symbol='${f_symbol}', type='$f_type', amount=${f_amount}, side='${f_side_opposide}', price='None', ${f_params}" + [[ $f_params =~ reduceOnly ]] && local f_order="symbol='${f_symbol}', type='$f_type', amount=${f_amount}, side='${f_side_opposide}', price=$f_price, ${f_params}" echo "$f_order" | notify.sh -s "ORDER" f_ccxt "print($STOCK_EXCHANGE.createOrder(${f_order}))" || return 1