check for empty vars

This commit is contained in:
olli 2023-05-25 15:21:03 +02:00
parent d9398b4fcc
commit 103487790d

View File

@ -113,6 +113,8 @@ function check_sell_conditions_strategy {
# check if the result (profit/loss until now) is lowering and sell if too low () # check if the result (profit/loss until now) is lowering and sell if too low ()
if [ -f ${f_TRADE_HIST_FILE_INTERIM} ] if [ -f ${f_TRADE_HIST_FILE_INTERIM} ]
then
if [ -n "$SELL_IF_LAST_RATE_LOWER_THEN" ]
then then
local f_BUY_PRICE_2ND_LAST_RATE_DIFF=$(tail -n2 ${f_TRADE_HIST_FILE_INTERIM} | head -n1) local f_BUY_PRICE_2ND_LAST_RATE_DIFF=$(tail -n2 ${f_TRADE_HIST_FILE_INTERIM} | head -n1)
local f_diff_result=$(echo "${f_BUY_PRICE_LAST_RATE_DIFF} - (${f_BUY_PRICE_2ND_LAST_RATE_DIFF})" | bc | sed 's/^\./0./; s/^-\./-0./') local f_diff_result=$(echo "${f_BUY_PRICE_LAST_RATE_DIFF} - (${f_BUY_PRICE_2ND_LAST_RATE_DIFF})" | bc | sed 's/^\./0./; s/^-\./-0./')
@ -120,7 +122,10 @@ function check_sell_conditions_strategy {
then then
f_SELL="Loss between last (${f_BUY_PRICE_LAST_RATE_DIFF}%) and 2nd last (${f_BUY_PRICE_2ND_LAST_RATE_DIFF}%) rate/result more then ${SELL_IF_LAST_RATE_LOWER_THEN}% (${f_diff_result}%)" f_SELL="Loss between last (${f_BUY_PRICE_LAST_RATE_DIFF}%) and 2nd last (${f_BUY_PRICE_2ND_LAST_RATE_DIFF}%) rate/result more then ${SELL_IF_LAST_RATE_LOWER_THEN}% (${f_diff_result}%)"
fi fi
fi
if [ -n "$SELL_IF_LOWER_THEN_FEE_AFTER_PERIOD" ]
then
# Sell if the last X time units is lower then FEE # Sell if the last X time units is lower then FEE
if [ $(cat ${f_TRADE_HIST_FILE_INTERIM} | wc -l) -ge ${SELL_IF_LOWER_THEN_FEE_AFTER_PERIOD} ] if [ $(cat ${f_TRADE_HIST_FILE_INTERIM} | wc -l) -ge ${SELL_IF_LOWER_THEN_FEE_AFTER_PERIOD} ]
then then
@ -132,13 +137,16 @@ function check_sell_conditions_strategy {
fi fi
fi fi
fi fi
fi
# Sell on MACD Condition # Sell on MACD Condition
if [ -n "$SELL_MACD_RELATION_FROM" ]
then
if [ $(echo "${f_macd_histogram_relation} < ${SELL_MACD_RELATION_FROM}" | bc -l) -ne 0 ] if [ $(echo "${f_macd_histogram_relation} < ${SELL_MACD_RELATION_FROM}" | bc -l) -ne 0 ]
then then
f_SELL="MACD condition met" f_SELL="MACD condition met"
fi fi
fi
# Sell on RSI conditions # Sell on RSI conditions
if \ if \