new buy checks: BUY_DONT_WHEN_LAST_RATE_LOWER_THEN, BUY_DONT_WHEN_LAST_RATE_HIGHTER_THEN, BUY_DONT_WHEN_LAST_RATE_NEGATIVE

This commit is contained in:
olli 2023-06-01 14:43:26 +02:00
parent 86a5db5ec7
commit 3d39ce69ad
2 changed files with 39 additions and 8 deletions

View File

@ -31,7 +31,7 @@ function check_buy_conditions {
if check_buy_conditions_strategy ${f_ASSET_HIST_FILE} ${f_strategy} if check_buy_conditions_strategy ${f_ASSET_HIST_FILE} ${f_strategy}
then then
f_BUY="${f_echo_prefix} All BUY conditions met!!! f_BUY="${f_echo_prefix} All BUY conditions met!!!
${f_last_line},${f_market_performance}" ${f_last_line}"
break break
fi fi
done done
@ -123,7 +123,7 @@ function check_buy_conditions_strategy {
# Check market-performance # Check market-performance
if [ $(echo "${f_market_performance} > ${GOOD_MARKET_PERFORMANCE_INDEX}" | bc -l) -eq 0 ] if [ $(echo "${f_market_performance} > ${GOOD_MARKET_PERFORMANCE_INDEX}" | bc -l) -eq 0 ]
then then
echo " --> ${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 return 1
fi fi
@ -132,19 +132,19 @@ function check_buy_conditions_strategy {
local f_pricediff=$(g_percentage-diff "$f_priceXago" "$f_pricenow") local f_pricediff=$(g_percentage-diff "$f_priceXago" "$f_pricenow")
if [ $(echo "${f_pricediff} < ${BUY_MINGROWTH}" | bc -l) -ne 0 ] if [ $(echo "${f_pricediff} < ${BUY_MINGROWTH}" | bc -l) -ne 0 ]
then then
echo " --> ${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 return 1
fi fi
# Check MACD # Check MACD
if [ $(echo "${f_macd_histogram_relation} < ${BUY_MACD_RELATION_FROM}" | bc -l) -ne 0 ] if [ $(echo "${f_macd_histogram_relation} < ${BUY_MACD_RELATION_FROM}" | bc -l) -ne 0 ]
then then
echo " --> ${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 return 1
fi fi
if [ $(echo "${f_macd_histogram_relation} > ${BUY_MACD_RELATION_TO}" | bc -l) -ne 0 ] if [ $(echo "${f_macd_histogram_relation} > ${BUY_MACD_RELATION_TO}" | bc -l) -ne 0 ]
then then
echo " --> ${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 return 1
fi fi
@ -169,7 +169,7 @@ function check_buy_conditions_strategy {
then then
echo "${f_echo_prefix}RSI conditions met" >/dev/null echo "${f_echo_prefix}RSI conditions met" >/dev/null
else else
echo " --> ${f_echo_prefix}RSI conditions NOT met" echo " ${f_echo_prefix}RSI conditions NOT met"
return 1 return 1
fi fi
@ -182,9 +182,40 @@ function check_buy_conditions_strategy {
then then
echo "${f_echo_prefix}Price change conditions met" >/dev/null echo "${f_echo_prefix}Price change conditions met" >/dev/null
else else
echo " --> ${f_echo_prefix}Price change conditions NOT met" echo " ${f_echo_prefix}Price change conditions NOT met"
return 1 return 1
fi fi
# after high change in one period next price often falls
if [ -n "${BUY_DONT_WHEN_LAST_RATE_HIGHER_THEN}" ]
then
if [ $(echo "${f_price_change} > ${BUY_DONT_WHEN_LAST_RATE_HIGHER_THEN}" | bc -l) -ne 0 ]
then
echo " ${f_echo_prefix}BUY_DONT_WHEN_LAST_RATE_HIGHER_THEN (${BUY_DONT_WHEN_LAST_RATE_HIGHER_THEN}) met"
return 1
fi
fi
if [ -n "${BUY_DONT_WHEN_LAST_RATE_LOWER_THEN}" ]
then
if [ $(echo "${f_price_change} < ${BUY_DONT_WHEN_LAST_RATE_LOWER_THEN}" | bc -l) -ne 0 ]
then
echo " ${f_echo_prefix}BUY_DONT_WHEN_LAST_RATE_LOWER_THEN (${BUY_DONT_WHEN_LAST_RATE_LOWER_THEN}) met"
return 1
fi
fi
# dont buy on negative last result
if [ "${BUY_DONT_WHEN_LAST_RATE_NEGATIVE}" = true ]
then
if echo "${f_price_change}" | grep -q "^-"
then
echo " ${f_echo_prefix}BUY_DONT_WHEN_LAST_RATE_NEGATIVE met"
return 1
fi
fi
} }

View File

@ -201,7 +201,7 @@ function check_sell_conditions_strategy {
then then
if [ $(echo "(${f_BUY_PRICE_LAST_RATE_DIFF} + -${FEE}) < 0" | bc -l) -ne 0 ] if [ $(echo "(${f_BUY_PRICE_LAST_RATE_DIFF} + -${FEE}) < 0" | bc -l) -ne 0 ]
then then
echo " --> 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="" f_SELL=""
fi fi
fi fi