multiple strategies, default config

This commit is contained in:
2023-05-09 17:04:02 +02:00
parent 1e5b8cff15
commit b223747c3e
16 changed files with 233 additions and 355 deletions

View File

@@ -1,6 +1,7 @@
function check_buy_conditions {
local f_ASSET_HIST_FILE="$1"
local f_strategy="$2"
f_ASSET=$(basename ${f_ASSET_HIST_FILE} | cut -d\. -f1)
if [ -n "${BOT}" ]
@@ -12,33 +13,48 @@ function check_buy_conditions {
return 0
fi
fi
# get asset vars
get_vars_from_csv "${f_ASSET_HIST_FILE}" || return 1
### from here: check for defined state to buy
f_BUY="${f_last_line}"
# load strategy
local f_echo_prefix="BUY ${f_ASSET}@${CURRENCY}:${f_price}:${f_strategy} - "
if [ -s "${f_strategy}" ]
then
. "${f_strategy}" || return 0
else
g_echo_note "${f_echo_prefix}Strategy file not found"
return 1
fi
g_echo_note "${f_echo_prefix}Running BUY checks"
# 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"
return 0
fi
local f_priceXago=$(tail -n${BUY_MINGROWTH_PERIOD} ${f_ASSET_HIST_FILE} | grep ^[0-9] | head -n1 | cut -d, -f2)
local f_pricenow=$(echo ${f_last_line} | grep ^[0-9] | cut -d, -f2)
local f_pricediff=$(g_percentage-diff "$f_priceXago" "$f_pricenow")
if [ $(echo "${f_pricediff} < ${BUY_MINGROWTH}" | bc -l) -ne 0 ]
then
g_echo_note "BUY ${f_ASSET}@${CURRENCY}:${f_price}: With ${f_pricediff} under ${BUY_MINGROWTH}% growth in the last ${BUY_MINGROWTH_PERIOD} time periods"
g_echo_note "${f_echo_prefix}With ${f_pricediff} under ${BUY_MINGROWTH}% growth in the last ${BUY_MINGROWTH_PERIOD} time periods"
return 0
fi
#local f_macd_histogram_max=$(tail -n26 "${f_ASSET_HIST_FILE}" | cut -d"," -f8 | egrep "^[0-9]|^-[0-9]" | sed 's/^-//' | sort -n | tail -n1)
#local f_macd_histogram_relation=$(echo "100+$(g_percentage-diff ${f_macd_histogram_max} ${f_macd_histogram})" | bc | cut -d\. -f1)
# MACD
# no negative or empty values
echo "${f_macd_histogram_relation}" | grep -q "^[0-9]" || return 0
# 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 "BUY ${f_ASSET}@${CURRENCY}:${f_price}: MACD conditions NOT met"
g_echo_note "${f_echo_prefix}MACD conditions NOT met"
return 0
fi
@@ -62,9 +78,9 @@ function check_buy_conditions {
[ ${f_rsi420} -ge ${BUY_RSI420_SIGNAL_FROM} ] && \
[ ${f_rsi720} -ge ${BUY_RSI720_SIGNAL_FROM} ]
then
echo "BUY ${f_ASSET}@${CURRENCY}:${f_price}: RSI conditions met" >/dev/null
echo "${f_echo_prefix}RSI conditions met" >/dev/null
else
g_echo_note "BUY ${f_ASSET}@${CURRENCY}:${f_price}: RSI conditions NOT met"
g_echo_note "${f_echo_prefix}RSI conditions NOT met"
return 0
fi
@@ -76,9 +92,9 @@ function check_buy_conditions {
[ $(echo "${f_price_change_14_day} > ${BUY_MIN_PRICE_CHANGE_LAST_14_DAY}" | bc -l) -ne 0 ] && \
[ $(echo "${f_price_change_30_day} > ${BUY_MIN_PRICE_CHANGE_LAST_30_DAY}" | bc -l) -ne 0 ]
then
echo "BUY ${f_ASSET}@${CURRENCY}:${f_price}: Price change conditions met" >/dev/null
echo "${f_echo_prefix}Price change conditions met" >/dev/null
else
g_echo_note "BUY ${f_ASSET}@${CURRENCY}:${f_price}: Price change conditions NOT met"
g_echo_note "${f_echo_prefix}Price change conditions NOT met"
return 0
fi
@@ -88,7 +104,7 @@ function check_buy_conditions {
# Check for beginning MACD Trend
if ! tail -n3 ${f_ASSET_HIST_FILE} | grep -q '|buy,'
then
g_echo_note "BUY ${f_ASSET}@${CURRENCY}:${f_price}: MACD Trend not near (3 timeframes) the beginning buy signal"
g_echo_note "${f_echo_prefix}MACD Trend not near (3 timeframes) the beginning buy signal"
return 0
fi
@@ -119,7 +135,7 @@ function check_buy_conditions {
then
echo "${f_last_line},${f_ASSET}" >>trade.log
f_BUY="BUY ${f_ASSET}@${CURRENCY}:${f_price}: All BUY conditions met!!!
f_BUY="${f_echo_prefix}All BUY conditions met!!!
${f_BUY}"
g_echo_note "${f_BUY}"