more pure bash to speed up things
This commit is contained in:
parent
411b4ee940
commit
9a9e08fb36
@ -26,9 +26,14 @@ function check_buy_conditions {
|
|||||||
f_BUY=""
|
f_BUY=""
|
||||||
|
|
||||||
# run strategies
|
# run strategies
|
||||||
|
if [ -z "$f_buy_strategies_array" ]
|
||||||
|
then
|
||||||
local f_strategy_path=../../strategies
|
local f_strategy_path=../../strategies
|
||||||
[ -z "${BOT}" ] && f_strategy_path=strategies
|
[ -z "${BOT}" ] && f_strategy_path=strategies
|
||||||
for f_strategy in $(find ${f_strategy_path} -name "buy.*.conf" -type f)
|
mapfile -t f_buy_strategies_array < <(find ${f_strategy_path} -name "buy.*.conf" -type f)
|
||||||
|
fi
|
||||||
|
#for f_strategy in $(find ${f_strategy_path} -name "buy.*.conf" -type f)
|
||||||
|
for f_strategy in "${f_buy_strategies_array[@]}"
|
||||||
do
|
do
|
||||||
f_echo_prefix="BUY ${f_ASSET}@${CURRENCY}:${f_price}:${f_strategy} - "
|
f_echo_prefix="BUY ${f_ASSET}@${CURRENCY}:${f_price}:${f_strategy} - "
|
||||||
if check_buy_conditions_strategy ${f_ASSET_HIST_FILE} ${f_strategy}
|
if check_buy_conditions_strategy ${f_ASSET_HIST_FILE} ${f_strategy}
|
||||||
@ -113,15 +118,16 @@ function check_buy_conditions_strategy {
|
|||||||
# 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} - "
|
||||||
f_do_buy=""
|
f_do_buy=""
|
||||||
if [ -s "${f_strategy}" ]
|
|
||||||
then
|
|
||||||
. "${f_strategy}" || return 1
|
|
||||||
else
|
|
||||||
g_echo_note "${f_echo_prefix}Strategy file not found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
[ -n "${BOT}" ] && g_echo_note "${f_echo_prefix}Running BUY checks"
|
[ -n "${BOT}" ] && g_echo_note "${f_echo_prefix}Running BUY checks"
|
||||||
|
|
||||||
|
#if [ -s "${f_strategy}" ]
|
||||||
|
#then
|
||||||
|
. "${f_strategy}" || return 1
|
||||||
|
#else
|
||||||
|
# g_echo_note "${f_echo_prefix}Strategy file not found"
|
||||||
|
# return 1
|
||||||
|
#fi
|
||||||
|
|
||||||
# Check buy signal from strategy
|
# Check buy signal from strategy
|
||||||
if [ -n "${f_do_buy}" ]
|
if [ -n "${f_do_buy}" ]
|
||||||
then
|
then
|
||||||
@ -130,103 +136,5 @@ function check_buy_conditions_strategy {
|
|||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
########## Obsolete Code #############
|
|
||||||
# if [ $(echo "${f_market_performance} > ${GOOD_MARKET_PERFORMANCE_INDEX}" | bc -l) -eq 0 ]
|
|
||||||
# then
|
|
||||||
# echo " ${f_echo_prefix}BUY market performance ${f_market_performance}% looks bad - Dont buy anything"
|
|
||||||
# return 1
|
|
||||||
# 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
|
|
||||||
# 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
|
|
||||||
# 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
|
|
||||||
# echo " ${f_echo_prefix}MACD Relation with ${f_macd_histogram_relation}% over BUY_MACD_RELATION_TO ${BUY_MACD_RELATION_TO}%"
|
|
||||||
# return 1
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# # RSI
|
|
||||||
# if \
|
|
||||||
# [ ${f_rsi5} -le ${BUY_RSI5_SIGNAL_UNTIL} ] && \
|
|
||||||
# [ ${f_rsi14} -le ${BUY_RSI14_SIGNAL_UNTIL} ] && \
|
|
||||||
# [ ${f_rsi21} -le ${BUY_RSI21_SIGNAL_UNTIL} ] && \
|
|
||||||
# [ ${f_rsi60} -le ${BUY_RSI60_SIGNAL_UNTIL} ] && \
|
|
||||||
# [ ${f_rsi120} -le ${BUY_RSI120_SIGNAL_UNTIL} ] && \
|
|
||||||
# [ ${f_rsi240} -le ${BUY_RSI240_SIGNAL_UNTIL} ] && \
|
|
||||||
# [ ${f_rsi420} -le ${BUY_RSI420_SIGNAL_UNTIL} ] && \
|
|
||||||
# [ ${f_rsi720} -le ${BUY_RSI720_SIGNAL_UNTIL} ] && \
|
|
||||||
# [ ${f_rsi5} -ge ${BUY_RSI5_SIGNAL_FROM} ] && \
|
|
||||||
# [ ${f_rsi14} -ge ${BUY_RSI14_SIGNAL_FROM} ] && \
|
|
||||||
# [ ${f_rsi21} -ge ${BUY_RSI21_SIGNAL_FROM} ] && \
|
|
||||||
# [ ${f_rsi60} -ge ${BUY_RSI60_SIGNAL_FROM} ] && \
|
|
||||||
# [ ${f_rsi120} -ge ${BUY_RSI120_SIGNAL_FROM} ] && \
|
|
||||||
# [ ${f_rsi240} -ge ${BUY_RSI240_SIGNAL_FROM} ] && \
|
|
||||||
# [ ${f_rsi420} -ge ${BUY_RSI420_SIGNAL_FROM} ] && \
|
|
||||||
# [ ${f_rsi720} -ge ${BUY_RSI720_SIGNAL_FROM} ]
|
|
||||||
# then
|
|
||||||
# echo "${f_echo_prefix}RSI conditions met" >/dev/null
|
|
||||||
# else
|
|
||||||
# echo " ${f_echo_prefix}RSI conditions NOT met"
|
|
||||||
# return 1
|
|
||||||
# fi
|
|
||||||
#
|
|
||||||
# # Price change
|
|
||||||
# if \
|
|
||||||
# [ $(echo "${f_price_change_1_day} > ${BUY_MIN_PRICE_CHANGE_LAST_1_DAY}" | bc -l) -ne 0 ] && \
|
|
||||||
# [ $(echo "${f_price_change_7_day} > ${BUY_MIN_PRICE_CHANGE_LAST_7_DAY}" | bc -l) -ne 0 ] && \
|
|
||||||
# [ $(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 "${f_echo_prefix}Price change conditions met" >/dev/null
|
|
||||||
# else
|
|
||||||
# echo " ${f_echo_prefix}Price change conditions NOT met"
|
|
||||||
# return 1
|
|
||||||
# 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
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,16 @@ function check_sell_conditions {
|
|||||||
echo ${f_BUY_PRICE_LAST_RATE_DIFF} >>${f_TRADE_HIST_FILE_INTERIM}
|
echo ${f_BUY_PRICE_LAST_RATE_DIFF} >>${f_TRADE_HIST_FILE_INTERIM}
|
||||||
|
|
||||||
# run strategies
|
# run strategies
|
||||||
f_strategy_path=../../strategies
|
# f_strategy_path=../../strategies
|
||||||
|
# [ -z "${BOT}" ] && f_strategy_path=strategies
|
||||||
|
if [ -z "$f_sell_strategies_array" ]
|
||||||
|
then
|
||||||
|
local f_strategy_path=../../strategies
|
||||||
[ -z "${BOT}" ] && f_strategy_path=strategies
|
[ -z "${BOT}" ] && f_strategy_path=strategies
|
||||||
for f_strategy in $(find ${f_strategy_path} -name "sell.*.conf" -type f)
|
mapfile -t f_sell_strategies_array < <(find ${f_strategy_path} -name "sell.*.conf" -type f)
|
||||||
|
fi
|
||||||
|
# for f_strategy in $(find ${f_strategy_path} -name "sell.*.conf" -type f)
|
||||||
|
for f_strategy in "${f_buy_strategies_array[@]}"
|
||||||
do
|
do
|
||||||
f_echo_prefix="SELL ${f_ASSET}@${CURRENCY}:${f_price}:${f_strategy} - "
|
f_echo_prefix="SELL ${f_ASSET}@${CURRENCY}:${f_price}:${f_strategy} - "
|
||||||
check_sell_conditions_strategy ${f_ASSET_HIST_FILE} ${f_strategy} ${f_TRADE_HIST_FILE} ${f_TRADE_HIST_FILE_INTERIM} ${f_BUY_PRICE} ${f_BUY_PRICE_LAST_RATE_DIFF}
|
check_sell_conditions_strategy ${f_ASSET_HIST_FILE} ${f_strategy} ${f_TRADE_HIST_FILE} ${f_TRADE_HIST_FILE_INTERIM} ${f_BUY_PRICE} ${f_BUY_PRICE_LAST_RATE_DIFF}
|
||||||
@ -122,21 +129,22 @@ function check_sell_conditions_strategy {
|
|||||||
|
|
||||||
f_do_sell=""
|
f_do_sell=""
|
||||||
|
|
||||||
# run strategy
|
|
||||||
if [ -s "${f_strategy}" ]
|
|
||||||
then
|
|
||||||
[ -z "${BOT}" ] && local f_strategy_name=$(echo ${f_strategy} | cut -d. -f2)
|
|
||||||
[ -n "${BOT}" ] && local f_strategy_name=$(echo ${f_strategy} | cut -d. -f6)
|
|
||||||
#if grep -q "buy.${f_strategy_name}.conf" ${f_TRADE_HIST_FILE}
|
|
||||||
#then
|
|
||||||
# . "${f_strategy}" || return 0
|
|
||||||
#fi
|
|
||||||
else
|
|
||||||
g_echo_note "${f_echo_prefix}Strategy file not found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
[ -n "${BOT}" ] && g_echo_note "${f_echo_prefix}Running SELL checks"
|
[ -n "${BOT}" ] && g_echo_note "${f_echo_prefix}Running SELL checks"
|
||||||
|
|
||||||
|
# run strategy
|
||||||
|
# if [ -s "${f_strategy}" ]
|
||||||
|
# then
|
||||||
|
# [ -z "${BOT}" ] && local f_strategy_name=$(echo ${f_strategy} | cut -d. -f2)
|
||||||
|
# [ -n "${BOT}" ] && local f_strategy_name=$(echo ${f_strategy} | cut -d. -f6)
|
||||||
|
# #if grep -q "buy.${f_strategy_name}.conf" ${f_TRADE_HIST_FILE}
|
||||||
|
# #then
|
||||||
|
. "${f_strategy}" || return 0
|
||||||
|
# #fi
|
||||||
|
# else
|
||||||
|
# g_echo_note "${f_echo_prefix}Strategy file not found"
|
||||||
|
# return 1
|
||||||
|
# fi
|
||||||
|
|
||||||
# Check sell signal from strategy
|
# Check sell signal from strategy
|
||||||
if [ -n "${f_do_sell}" ]
|
if [ -n "${f_do_sell}" ]
|
||||||
then
|
then
|
||||||
|
@ -16,7 +16,7 @@ function get_vars_from_csv {
|
|||||||
# read last 4 lines in array if not given
|
# read last 4 lines in array if not given
|
||||||
if [ -z "${f_last_lines_array}" ]
|
if [ -z "${f_last_lines_array}" ]
|
||||||
then
|
then
|
||||||
mapfile -t f_last_lines_array <<< $(tail -n4 "${f_ASSET_HIST_FILE}")
|
mapfile -t f_last_lines_array < <(tail -n4 "${f_ASSET_HIST_FILE}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if there are not four lines
|
# if there are not four lines
|
||||||
|
Loading…
Reference in New Issue
Block a user