From 8b83d450d0289c664db8a9c8e1d2ebeb449c86a2 Mon Sep 17 00:00:00 2001 From: olli Date: Mon, 16 Dec 2024 16:12:17 +0100 Subject: [PATCH] fix asset_amount: --- dabo/functions/order.sh | 45 +++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/dabo/functions/order.sh b/dabo/functions/order.sh index 5666457..a4c112e 100644 --- a/dabo/functions/order.sh +++ b/dabo/functions/order.sh @@ -70,6 +70,29 @@ function order { ### validity checks end ### + + # get amount in target asset + if [[ $f_amount =~ ^asset_amount: ]] + then + # if given in target + f_amount=${f_amount//asset_amount:} + else + # on market order use current price + if [[ $f_type = market ]] + then + # if given in $CURRENCY + local f_asset=${f_symbol///*} + currency_converter $f_amount $CURRENCY $f_asset || return 1 + f_amount=$f_currency_converter_result + # on limit order use limit price + elif [[ $f_type = limit ]] + then + g_calc "1/${f_price}*${f_amount}" + f_amount=$g_calc_result + fi + fi + + # check for swap/margin trades if [ -n "$LEVERAGE" ] && [[ $f_price != stoploss ]] && [[ $f_price != takeprofit ]] then @@ -97,28 +120,6 @@ function order { fi - # get amount in crypto asset - if [[ $f_amount =~ ^asset_amount: ]] - then - # if given in crypto - f_amount=${f_amount//asset_amount:} - else - # on market order use current price - if [[ $f_type = market ]] - then - # if given in $CURRENCY - local f_asset=${f_symbol///*} - currency_converter $f_amount $CURRENCY $f_asset || return 1 - f_amount=$f_currency_converter_result - # on limit order use limit price - elif [[ $f_type = limit ]] - then - g_calc "1/${f_price}*${f_amount}" - f_amount=$g_calc_result - fi - fi - - # Add stoploss and take profit if available if [ -n "$f_stoploss" ] then