fixes tp/sl
This commit is contained in:
parent
21125e84e5
commit
76f556b1ad
@ -94,7 +94,7 @@ function order {
|
|||||||
|
|
||||||
|
|
||||||
# check for swap/margin trades
|
# check for swap/margin trades
|
||||||
if [ -n "$LEVERAGE" ] && [[ $f_price != stoploss ]] && [[ $f_price != takeprofit ]]
|
if [ -n "$LEVERAGE" ]
|
||||||
then
|
then
|
||||||
# do some margin things
|
# do some margin things
|
||||||
|
|
||||||
@ -110,10 +110,13 @@ function order {
|
|||||||
# define margin mode isolated/cross
|
# define margin mode isolated/cross
|
||||||
#[[ $f_type =~ limit|market ]] &&
|
#[[ $f_type =~ limit|market ]] &&
|
||||||
f_params="${f_params}'marginMode': '$MARGIN_MODE', "
|
f_params="${f_params}'marginMode': '$MARGIN_MODE', "
|
||||||
|
|
||||||
# calculate amount with leverage
|
# calculate amount with leverage
|
||||||
g_calc "${f_amount}*${LEVERAGE}"
|
if [[ $f_price != stoploss ]] && [[ $f_price != takeprofit ]]
|
||||||
f_amount=$g_calc_result
|
then
|
||||||
|
g_calc "${f_amount}*${LEVERAGE}"
|
||||||
|
f_amount=$g_calc_result
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# short/sell not possible in spot market
|
# short/sell not possible in spot market
|
||||||
[[ $f_side =~ ^sell$ ]] || return 1
|
[[ $f_side =~ ^sell$ ]] || return 1
|
||||||
@ -148,7 +151,8 @@ function order {
|
|||||||
elif [[ $f_type = "stoploss" ]]
|
elif [[ $f_type = "stoploss" ]]
|
||||||
then
|
then
|
||||||
f_type="market"
|
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
|
||||||
fi
|
fi
|
||||||
if [ -n "$f_takeprofit" ]
|
if [ -n "$f_takeprofit" ]
|
||||||
@ -174,7 +178,8 @@ function order {
|
|||||||
if [[ $f_type = "takeprofit" ]]
|
if [[ $f_type = "takeprofit" ]]
|
||||||
then
|
then
|
||||||
f_type="limit"
|
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
|
||||||
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}"
|
[[ $f_type = market ]] && local f_order="symbol='${f_symbol}', type='$f_type', amount=${f_amount}, side='${f_side}', ${f_params}"
|
||||||
|
|
||||||
# takeprofit/stoploss only
|
# 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"
|
echo "$f_order" | notify.sh -s "ORDER"
|
||||||
f_ccxt "print($STOCK_EXCHANGE.createOrder(${f_order}))" || return 1
|
f_ccxt "print($STOCK_EXCHANGE.createOrder(${f_order}))" || return 1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user