This commit is contained in:
olli 2023-05-19 08:02:34 +02:00
parent 7d27642d9a
commit 212b1d088c
4 changed files with 32 additions and 18 deletions

View File

@ -18,7 +18,7 @@ function check_buy_conditions {
get_vars_from_csv "${f_ASSET_HIST_FILE}" || return 1 get_vars_from_csv "${f_ASSET_HIST_FILE}" || return 1
### from here: check for defined state to buy ### from here: check for defined state to buy
f_BUY="${f_last_line}" f_BUY="${f_last_line},${f_market_performance}"
# load strategy # load strategy
local f_echo_prefix="BUY ${f_ASSET}@${CURRENCY}:${f_price}:${f_strategy} - " local f_echo_prefix="BUY ${f_ASSET}@${CURRENCY}:${f_price}:${f_strategy} - "
@ -112,15 +112,29 @@ function check_buy_conditions {
return 0 return 0
fi fi
# if [ -n "$f_BUY" ] if [ -n "$f_BUY" ]
# then then
# # Check for beginning MACD Trend # # Check for beginning MACD Trend
# if ! tail -n3 ${f_ASSET_HIST_FILE} | grep -q '|buy,' # if ! tail -n3 ${f_ASSET_HIST_FILE} | grep -q '|buy,'
# then # then
# g_echo_note "${f_echo_prefix}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 # return 0
# fi # 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 0
# fi
# # Check for growing MACD trend # # 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_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_2before=$(tail -n3 ${f_ASSET_HIST_FILE} | head -n1 | cut -d, -f8)
@ -137,7 +151,7 @@ function check_buy_conditions {
# 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" # 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 0 # return 0
# fi # fi
# fi fi
### Buy or not buy? ### Buy or not buy?
# BOT # BOT

View File

@ -10,17 +10,7 @@ function check_sell_conditions {
# get data # get data
get_vars_from_csv ${f_ASSET_HIST_FILE} || return 1 get_vars_from_csv ${f_ASSET_HIST_FILE} || return 1
# load strategy
local f_echo_prefix="SELL ${f_ASSET}@${CURRENCY}:${f_price}:${f_strategy} - " local f_echo_prefix="SELL ${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 SELL checks"
### check current result ### check current result
if [ -n "${BOT}" ] if [ -n "${BOT}" ]
@ -46,6 +36,15 @@ function check_sell_conditions {
echo "INTERIM RESULT: ${f_BUY_PRICE_LAST_RATE_DIFF}%" echo "INTERIM RESULT: ${f_BUY_PRICE_LAST_RATE_DIFF}%"
fi fi
# run 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 SELL checks"
# 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} ]

View File

@ -15,8 +15,8 @@ function get_rsi_indicator {
local f_period_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d, -f2 | grep "^[0-9]" | wc -l) local f_period_sum=$(tail -n${f_period} "${f_hist_file}" | cut -d, -f2 | grep "^[0-9]" | wc -l)
if ! [ ${f_period_sum} -ge ${f_period} ] if ! [ ${f_period_sum} -ge ${f_period} ]
then then
g_echo_note "${FUNCNAME} $@: Not enough data - waiting for more values. (${f_period} needed; ${f_period_sum} given)" g_echo_note "${FUNCNAME} $@: Not enough data - waiting for more values and defaulting to 50. (${f_period} needed; ${f_period_sum} given)"
echo -n ",${f_rsi}" >>"${f_hist_file}" echo -n ",50" >>"${f_hist_file}"
return 0 return 0
fi fi

View File

@ -18,6 +18,7 @@ function get_vars_from_csv {
get_var_from_line macd_histogram 8 get_var_from_line macd_histogram 8
get_var_from_line macd_signal_relation 9 get_var_from_line macd_signal_relation 9
f_macd_histogram_relation=$(echo "${f_macd_signal_relation}" | cut -d\| -f1) f_macd_histogram_relation=$(echo "${f_macd_signal_relation}" | cut -d\| -f1)
[ -z "$f_macd_histogram_relation" ] && return 1
f_macd_histogram_signal=$(echo "${f_macd_signal_relation}" | cut -d\| -f2) f_macd_histogram_signal=$(echo "${f_macd_signal_relation}" | cut -d\| -f2)
get_var_from_line rsi5 10 get_var_from_line rsi5 10