price precision

This commit is contained in:
olli 2024-08-31 17:45:54 +02:00
parent fdc3013501
commit 5e07b0450b

View File

@ -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