diff --git a/dabo/functions/check_sell_conditions.sh b/dabo/functions/check_sell_conditions.sh index c023195..9aa9f38 100644 --- a/dabo/functions/check_sell_conditions.sh +++ b/dabo/functions/check_sell_conditions.sh @@ -12,6 +12,8 @@ function check_sell_conditions { f_echo_prefix="SELL ${f_ASSET}@${CURRENCY}:${f_price} - " ### check current result + + # bot if [ -n "${BOT}" ] then f_TRADE_HIST_FILE="$(ls -1tr trade-histories/trade-*${f_ASSET}-open.history.csv | tail -n1)" @@ -21,18 +23,41 @@ function check_sell_conditions { return 0 fi f_TRADE_HIST_FILE_INTERIM=$(echo ${f_TRADE_HIST_FILE} | sed 's/-open\.history\.csv$/-interim.history.csv/') - local f_BUY_PRICE=$(grep -i ',BUY,' $f_TRADE_HIST_FILE | tail -n1 | cut -d, -f5) - local f_BUY_PRICE_LAST_RATE_DIFF=$(g_percentage-diff ${f_BUY_PRICE} ${f_price}) - # Store for overview - echo ${f_BUY_PRICE_LAST_RATE_DIFF} >DIFF_BUY_PRICE_${f_ASSET} + f_BUY_PRICE=$(grep -i ',BUY,' $f_TRADE_HIST_FILE | tail -n1 | cut -d, -f5) else + # analyze + f_BUY_PRICE=${BUY_PRICE} f_TRADE_HIST_FILE="${g_tmp}/open-${tmpfile}" f_TRADE_HIST_FILE_INTERIM="${g_tmp}/interim-${tmpfile}" - f_BUY_PRICE_LAST_RATE_DIFF=$(g_percentage-diff ${BUY_PRICE} ${f_price}) - f_BUY_PRICE=${BUY_PRICE} - result=${f_BUY_PRICE_LAST_RATE_DIFF} echo "INTERIM RESULT: ${f_BUY_PRICE_LAST_RATE_DIFF}%" - fi + fi + result=${f_BUY_PRICE_LAST_RATE_DIFF} + f_result=${f_BUY_PRICE_LAST_RATE_DIFF} + + f_BUY_PRICE_LAST_RATE_DIFF=$(g_percentage-diff ${f_BUY_PRICE} ${f_price}) + +# if [ -n "${BOT}" ] +# then +# f_TRADE_HIST_FILE="$(ls -1tr trade-histories/trade-*${f_ASSET}-open.history.csv | tail -n1)" +# if ! [ -s "${f_TRADE_HIST_FILE}" ] +# then +# g_echo_note "${f_echo_prefix}No trade history file (${f_TRADE_HIST_FILE}) found - ignoring" +# return 0 +# fi +# f_TRADE_HIST_FILE_INTERIM=$(echo ${f_TRADE_HIST_FILE} | sed 's/-open\.history\.csv$/-interim.history.csv/') +# local f_BUY_PRICE=$(grep -i ',BUY,' $f_TRADE_HIST_FILE | tail -n1 | cut -d, -f5) +# local f_BUY_PRICE_LAST_RATE_DIFF=$(g_percentage-diff ${f_BUY_PRICE} ${f_price}) +# local f_result=f_BUY_PRICE_LAST_RATE_DIFF +# # Store for overview +# echo ${f_BUY_PRICE_LAST_RATE_DIFF} >DIFF_BUY_PRICE_${f_ASSET} +# else +# f_TRADE_HIST_FILE="${g_tmp}/open-${tmpfile}" +# f_TRADE_HIST_FILE_INTERIM="${g_tmp}/interim-${tmpfile}" +# f_BUY_PRICE_LAST_RATE_DIFF=$(g_percentage-diff ${BUY_PRICE} ${f_price}) +# f_BUY_PRICE=${BUY_PRICE} +# result=${f_BUY_PRICE_LAST_RATE_DIFF} +# echo "INTERIM RESULT: ${f_BUY_PRICE_LAST_RATE_DIFF}%" +# fi # store new interim result echo ${f_BUY_PRICE_LAST_RATE_DIFF} >>${f_TRADE_HIST_FILE_INTERIM}