fix asset_amount:

This commit is contained in:
olli 2024-12-16 16:12:17 +01:00
parent 6b51e610ff
commit 8b83d450d0

View File

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