optical fixes

This commit is contained in:
olli 2023-06-01 14:17:17 +02:00
parent 0829f533aa
commit 86a5db5ec7
2 changed files with 7 additions and 66 deletions

View File

@ -123,7 +123,7 @@ function check_buy_conditions_strategy {
# Check market-performance
if [ $(echo "${f_market_performance} > ${GOOD_MARKET_PERFORMANCE_INDEX}" | bc -l) -eq 0 ]
then
#g_echo_note "${f_echo_prefix}BUY market performance ${f_market_performance}% looks bad - Dont buy anything"
echo " --> ${f_echo_prefix}BUY market performance ${f_market_performance}% looks bad - Dont buy anything"
return 1
fi
@ -132,36 +132,22 @@ function check_buy_conditions_strategy {
local f_pricediff=$(g_percentage-diff "$f_priceXago" "$f_pricenow")
if [ $(echo "${f_pricediff} < ${BUY_MINGROWTH}" | bc -l) -ne 0 ]
then
g_echo_note "${f_echo_prefix}With ${f_pricediff} under ${BUY_MINGROWTH}% growth in the last ${BUY_MINGROWTH_PERIOD} time periods"
echo " --> ${f_echo_prefix}With ${f_pricediff} under ${BUY_MINGROWTH}% growth in the last ${BUY_MINGROWTH_PERIOD} time periods"
return 1
fi
# Check MACD
if [ $(echo "${f_macd_histogram_relation} < ${BUY_MACD_RELATION_FROM}" | bc -l) -ne 0 ]
then
#g_echo_note "${f_echo_prefix}MACD Relation with ${f_macd_histogram_relation}% under BUY_MACD_RELATION_FROM ${BUY_MACD_RELATION_FROM}%"
echo " --> ${f_echo_prefix}MACD Relation with ${f_macd_histogram_relation}% under BUY_MACD_RELATION_FROM ${BUY_MACD_RELATION_FROM}%"
return 1
fi
if [ $(echo "${f_macd_histogram_relation} > ${BUY_MACD_RELATION_TO}" | bc -l) -ne 0 ]
then
#g_echo_note "${f_echo_prefix}MACD Relation with ${f_macd_histogram_relation}% over BUY_MACD_RELATION_TO ${BUY_MACD_RELATION_TO}%"
echo " --> ${f_echo_prefix}MACD Relation with ${f_macd_histogram_relation}% over BUY_MACD_RELATION_TO ${BUY_MACD_RELATION_TO}%"
return 1
fi
## no negative or empty values
#if echo "${f_macd_histogram_relation}" | grep -q "^[0-9]"
#then
# # check for conditions
# if [ ${f_macd_histogram_relation} -le ${BUY_MACD_RELATION_FROM} ] || [ ${f_macd_histogram_relation} -ge ${BUY_MACD_RELATION_TO} ]
# then
# g_echo_note "${f_echo_prefix}MACD conditions NOT met"
# return 1
# fi
#else
# g_echo_note "${f_echo_prefix}f_macd_histogram_relation empty or negative"
# return 1
#fi
# RSI
if \
[ ${f_rsi5} -le ${BUY_RSI5_SIGNAL_UNTIL} ] && \
@ -183,7 +169,7 @@ function check_buy_conditions_strategy {
then
echo "${f_echo_prefix}RSI conditions met" >/dev/null
else
g_echo_note "${f_echo_prefix}RSI conditions NOT met"
echo " --> ${f_echo_prefix}RSI conditions NOT met"
return 1
fi
@ -196,50 +182,9 @@ function check_buy_conditions_strategy {
then
echo "${f_echo_prefix}Price change conditions met" >/dev/null
else
g_echo_note "${f_echo_prefix}Price change conditions NOT met"
echo " --> ${f_echo_prefix}Price change conditions NOT met"
return 1
fi
# if [ -n "$f_BUY" ]
# then
# # Check for beginning MACD Trend
# if ! tail -n3 ${f_ASSET_HIST_FILE} | grep -q '|buy,'
# then
# g_echo_note "${f_echo_prefix}MACD Trend not near (3 timeframes) the beginning buy signal"
# return 1
# fi
# # Check for continious growing price
# local f_price_before=$(tail -n2 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f2)
# local f_price_2before=$(tail -n3 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f2)
# local f_price_3before=$(tail -n4 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f2)
# if [ $(echo "${f_price} < ${f_price_before}" | bc -l) -ne 0 ] || \
# [ $(echo "${f_price_before} < ${f_price_2before}" | bc -l) -ne 0 ] || \
# [ $(echo "${f_price_2before} < ${f_price_3before}" | bc -l) -ne 0 ]
# then
# g_echo_note "${f_echo_prefix}Last 3 prices not continiously growing"
# return 1
# fi
# # Check for growing MACD trend
# local f_macd_histogram_before=$(tail -n2 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f8)
# local f_macd_histogram_2before=$(tail -n3 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f8)
# local f_macd_histogram_3before=$(tail -n4 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f8)
# local f_macd_histogram_4before=$(tail -n5 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f8)
# local f_macd_histogram_5before=$(tail -n6 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f8)
# if \
# [ $(echo "${f_macd_histogram} < ${f_macd_histogram_before}" | bc -l) -ne 0 ] && \
# [ $(echo "${f_macd_histogram_before} < ${f_macd_histogram_2before}" | bc -l) -ne 0 ] && \
# [ $(echo "${f_macd_histogram_2before} < ${f_macd_histogram_3before}" | bc -l) -ne 0 ] && \
# [ $(echo "${f_macd_histogram_3before} < ${f_macd_histogram_4before}" | bc -l) -ne 0 ] && \
# [ $(echo "${f_macd_histogram_4before} < ${f_macd_histogram_5before}" | bc -l) -ne 0 ]
# then
# g_echo_note "BUY ${f_ASSET}@${CURRENCY}:${f_price} MACD Histogram not rising (now ${f_macd_histogram} < 1 before ${f_macd_histogram_before} < 2 before ${f_macd_histogram_2before} < 3 before ${f_macd_histogram_3before} < 4 before ${f_macd_histogram_4before} < 5 before ${f_macd_histogram_5before}) - trend loses strength / not growing - don't buy"
# return 1
# fi
# fi
}

View File

@ -156,12 +156,8 @@ function check_sell_conditions_strategy {
# 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} ]
then
#local f_BUY_PRICE_XND_LAST_RATE_DIFF=$(tail -n${SELL_IF_LOWER_THEN_FEE_AFTER_PERIOD} ${f_TRADE_HIST_FILE_INTERIM} | head -n1)
#local f_diff_result=$(echo "${f_BUY_PRICE_LAST_RATE_DIFF} - (${f_BUY_PRICE_XND_LAST_RATE_DIFF})" | bc)
#if [ $(echo "${f_diff_result} < ${FEE}" | bc -l) -ne 0 ]
if [ $(echo "${f_BUY_PRICE_LAST_RATE_DIFF} < ${FEE}" | bc -l) -ne 0 ]
then
#f_SELL="Loss between last rate (${f_BUY_PRICE_LAST_RATE_DIFF}%) in ${SELL_IF_LOWER_THEN_FEE_AFTER_PERIOD} time units before more then ${FEE} (${f_diff_result}%)"
f_SELL="Result (${f_BUY_PRICE_LAST_RATE_DIFF}%) in more then ${SELL_IF_LOWER_THEN_FEE_AFTER_PERIOD} is under ${FEE}"
fi
fi
@ -205,7 +201,7 @@ function check_sell_conditions_strategy {
then
if [ $(echo "(${f_BUY_PRICE_LAST_RATE_DIFF} + -${FEE}) < 0" | bc -l) -ne 0 ]
then
g_echo_note "Result negative - holding (INTERIM RESULT ${f_BUY_PRICE_LAST_RATE_DIFF}% - FEE ${FEE}% < 0"
echo " --> Result negative - holding (INTERIM RESULT ${f_BUY_PRICE_LAST_RATE_DIFF}% - FEE ${FEE}% < 0"
f_SELL=""
fi
fi