no subshells for calculation
This commit is contained in:
@@ -59,7 +59,8 @@ function check_buy_conditions {
|
||||
g_echo_note "${f_BUY}"
|
||||
|
||||
# calculate quantity from balance for potentially invest
|
||||
local f_INVEST_QUANTITY=$(g_calc "scale=2; ${CURRENCY_BALANCE}/100*${INVEST}" | cut -d\. -f1)
|
||||
g_calc "scale=2; ${CURRENCY_BALANCE}/100*${INVEST}"
|
||||
local f_INVEST_QUANTITY=$(echo "${g_calc_result}" | cut -d\. -f1)
|
||||
g_echo_note "BUY current investment quantity is ${f_INVEST_QUANTITY} ${CURRENCY}"
|
||||
|
||||
# remove CURRENCY from asset
|
||||
@@ -72,17 +73,25 @@ function check_buy_conditions {
|
||||
|
||||
# use MIN_NOTIONAL+5% as INVEST_QUANTITY if INVEST_QUANTITY is under MIN_NOTIONAL
|
||||
# +5% in spite of MIN_NOTIONAL to be able to sell when the price falls a little bit
|
||||
[ $(g_calc "${f_INVEST_QUANTITY} < ${f_MIN_NOTIONAL}") -eq 0 ] || f_INVEST_QUANTITY=$(g_calc "scale=2; $f_MIN_NOTIONAL/100*105")
|
||||
#[ $(g_calc "${f_INVEST_QUANTITY} < ${f_MIN_NOTIONAL}") -eq 0 ] || f_INVEST_QUANTITY=$(g_calc "scale=2; $f_MIN_NOTIONAL/100*105")
|
||||
if ! g_num_is_lower.sh ${f_INVEST_QUANTITY} ${f_MIN_NOTIONAL}
|
||||
then
|
||||
g_calc "scale=2; ${f_MIN_NOTIONAL}/100*105"
|
||||
f_INVEST_QUANTITY=${g_calc_result}
|
||||
fi
|
||||
|
||||
|
||||
# if there is not enough balance for buying because ${f_MIN_NOTIONAL} needed for buying to sell (workaround)
|
||||
if [ $(g_calc "${CURRENCY_BALANCE} < ${f_MIN_NOTIONAL}*2") -ne 0 ]
|
||||
g_calc "${CURRENCY_BALANCE} < ${f_MIN_NOTIONAL}*2"
|
||||
if [ ${g_calc_result} -ne 0 ]
|
||||
then
|
||||
g_echo_note "BUY ${f_ASSET} not enough balance ${CURRENCY_BALANCE} for buying because of MIN_NOTIONAL (${f_MIN_NOTIONAL}*2) needed for buying-to-sell (workaround)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# continue if not balance enough for lowest quantity (MIN_NOTIONAL)
|
||||
if [ $(g_calc "${CURRENCY_BALANCE} > ${f_INVEST_QUANTITY}") -eq 0 ]
|
||||
g_calc "${CURRENCY_BALANCE} > ${f_INVEST_QUANTITY}"
|
||||
if [ ${g_calc_result} -eq 0 ]
|
||||
then
|
||||
g_echo_note "BUY ${f_ASSET} not enough balance (${CURRENCY_BALANCE}) for lowest quantity (MIN_NOTIONAL - ${f_INVEST_QUANTITY})"
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user