fix, calculating amount and leverage
This commit is contained in:
parent
f69d75b1b7
commit
c0a3e85888
@ -54,17 +54,6 @@ function order {
|
||||
|
||||
### validity checks end###
|
||||
|
||||
# get amount in crypto asset
|
||||
if [[ $f_amount =~ ^crypto_amount: ]]
|
||||
then
|
||||
# if given in crypto
|
||||
f_amount=${f_amount//crypto_amount:}
|
||||
else
|
||||
# if given in $CURRENCY
|
||||
local f_asset=${f_symbol///*}
|
||||
currency_converter $f_amount $CURRENCY $f_asset || return 1
|
||||
local f_amount=$f_currency_converter_result
|
||||
fi
|
||||
|
||||
# check for swap/margin trades
|
||||
if [ -n "$LEVERAGE" ]
|
||||
@ -83,11 +72,37 @@ function order {
|
||||
# define margibn mode isolated/cross
|
||||
f_params="${f_params}'marginMode': '$MARGIN_MODE', "
|
||||
|
||||
# calculate amount with leverage
|
||||
g_calc "${f_amount}*${LEVERAGE}"
|
||||
f_amount=$g_calc_result
|
||||
else
|
||||
# short/sell not possible in spot market
|
||||
[[ $f_side =~ ^sell$ ]] || return 1
|
||||
fi
|
||||
|
||||
|
||||
# get amount in crypto asset
|
||||
if [[ $f_amount =~ ^crypto_amount: ]]
|
||||
then
|
||||
# if given in crypto
|
||||
f_amount=${f_amount//crypto_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 stoploos and take profit if available
|
||||
if [ -n "$f_stoploss" ]
|
||||
then
|
||||
|
Loading…
Reference in New Issue
Block a user