From 5e07b0450b365d77cccbe311e46aedee2a88dc38 Mon Sep 17 00:00:00 2001 From: olli Date: Sat, 31 Aug 2024 17:45:54 +0200 Subject: [PATCH] price precision --- dabo/functions/order.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/dabo/functions/order.sh b/dabo/functions/order.sh index 49eea20..d86d404 100644 --- a/dabo/functions/order.sh +++ b/dabo/functions/order.sh @@ -89,14 +89,29 @@ function order { fi # Add stoploos and take profit if available - [ -n "$f_stoploss" ] && f_params="${f_params}'stopLossPrice': '$f_stoploss', " - [ -n "$f_takeprofit" ] && f_params="${f_params}'takeProfitPrice': '$f_takeprofit', " + if [ -n "$f_stoploss" ] + then + f_ccxt "print($STOCK_EXCHANGE.priceToPrecision('${f_symbol}', ${f_stoploss}))" + f_stoploss=$f_ccxt_result + f_params="${f_params}'stopLossPrice': '$f_stoploss', " + if [ -n "$f_takeprofit" ] + then + f_ccxt "print($STOCK_EXCHANGE.priceToPrecision('${f_symbol}', ${f_takeprofit}))" + f_takeprofit=$f_ccxt_result + f_params="${f_params}'takeProfitPrice': '$f_takeprofit', " + fi # end up params syntax with "}" f_params="${f_params}}" + # calculate price amount precision + f_ccxt "print($STOCK_EXCHANGE.amountToPrecision('${f_symbol}', ${f_amount}))" + f_amount=$f_ccxt_result + f_ccxt "print($STOCK_EXCHANGE.priceToPrecision('${f_symbol}', ${f_price}))" + f_price=$f_ccxt_result + # do the order - local f_order="symbol='${f_symbol}', type='$f_type', price=$f_price, amount='${f_amount}', side='${f_side}', ${f_params}" + local f_order="symbol='${f_symbol}', type='$f_type', price=$f_price, amount=${f_amount}, side='${f_side}', ${f_params}" echo "$f_order" | notify.sh -s "ORDER" f_ccxt "print($STOCK_EXCHANGE.createOrder(${f_order}))" || return 1