fix analyze.sh for multiple strategies
This commit is contained in:
parent
12d1dc08bc
commit
f59ce6054f
@ -186,6 +186,11 @@ Logs/Output:
|
||||
docker compose logs -f
|
||||
```
|
||||
|
||||
Update:
|
||||
```
|
||||
git pull -f --all
|
||||
```
|
||||
|
||||
|
||||
dabo-bot.sh is the bot that trades and collects the quotes and analyze.sh is the tool with which you can try out strategies with the historical data.
|
||||
The configuration files are called dabo-bot.conf and analyze.conf. analyze.sh also uses bot.conf but its variables are overwritten by analyze.conf if duplicated.
|
||||
|
@ -1,6 +1,11 @@
|
||||
# Default Config file for Dabo-Bot. Pleasse don't change!
|
||||
|
||||
# Timeframe analyze should be run egrep Regex possible
|
||||
ANALYZE_TIME="^2023-04-17"
|
||||
|
||||
. bot.conf
|
||||
# Verbosity
|
||||
ANALYZE_VERBOSE=0
|
||||
|
||||
# Run in batch mode and noch in parallel (usually only for debugging purposes)
|
||||
ANALYZE_BATCH=0
|
||||
|
||||
|
@ -16,13 +16,15 @@ function analyze {
|
||||
tmpfile=$(basename "${file}")
|
||||
|
||||
. /etc/bash/gaboshlib/g_percentage-diff.bashfunc
|
||||
. functions/check_buy_conditions.sh
|
||||
. functions/check_sell_conditions.sh
|
||||
. functions/get_vars_from_csv.sh
|
||||
. dabo/functions/check_buy_conditions.sh
|
||||
. dabo/functions/check_sell_conditions.sh
|
||||
. dabo/functions/get_vars_from_csv.sh
|
||||
. dabo/dabo-bot.conf
|
||||
. dabo-bot.conf
|
||||
. dabo-bot.override.conf
|
||||
. analyze.conf
|
||||
|
||||
touch ${g_tmp}/output-${tmpfile}
|
||||
tail -f ${g_tmp}/output-${tmpfile} &
|
||||
|
||||
#g_echo "Analyzing file: $file"
|
||||
|
||||
@ -38,27 +40,38 @@ function analyze {
|
||||
|
||||
ORIGIFS="$IFS"
|
||||
IFS=$'\n'
|
||||
local f_strategy
|
||||
for line in $(egrep "^${ANALYZE_TIME}" "$file")
|
||||
do
|
||||
IFS="$ORIGIFS"
|
||||
current=$(echo $line | cut -d, -f2)
|
||||
time=$(echo $line | cut -d, -f1 | cut -d: -f1,2)
|
||||
|
||||
echo "$line" >>${g_tmp}/${tmpfile}
|
||||
if [ -f "${g_tmp}/open-${tmpfile}" ]
|
||||
then
|
||||
check_sell_conditions ${g_tmp}/${tmpfile} >>${g_tmp}/output-${tmpfile} 2>&1
|
||||
for f_strategy in $(find strategies -name "sell.*.conf" -type f)
|
||||
do
|
||||
if [ "${ANALYZE_VERBOSE}" -eq "0" ]
|
||||
then
|
||||
check_sell_conditions ${g_tmp}/${tmpfile} "${f_strategy}" >>${g_tmp}/output-${tmpfile} 2>&1
|
||||
else
|
||||
check_sell_conditions ${g_tmp}/${tmpfile} "${f_strategy}" 2>&1 | tee -a ${g_tmp}/output-${tmpfile}
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if ! [ -f "${g_tmp}/open-${tmpfile}" ]
|
||||
then
|
||||
f_market_performance=$(grep "^$time" htdocs/botdata/MARKET_PERFORMANCE | tail -n1 | cut -d: -f4 | cut -d"%" -f1 | sed 's/ *//')
|
||||
f_market_performance=$(grep "^$time" data/botdata/MARKET_PERFORMANCE | tail -n1 | cut -d: -f4 | cut -d"%" -f1 | sed 's/ *//')
|
||||
[ -z "${f_market_performance}" ] && continue
|
||||
if [ $(echo "${f_market_performance} < ${GOOD_MARKET_PERFORMANCE_INDEX}" | bc -l) -eq 0 ]
|
||||
for f_strategy in $(find strategies -name "buy.*.conf" -type f)
|
||||
do
|
||||
if [ "${ANALYZE_VERBOSE}" -eq "0" ]
|
||||
then
|
||||
check_buy_conditions ${g_tmp}/${tmpfile} >>${g_tmp}/output-${tmpfile} 2>&1 || break
|
||||
check_buy_conditions ${g_tmp}/${tmpfile} "${f_strategy}" >>${g_tmp}/output-${tmpfile} 2>&1 || break
|
||||
else
|
||||
g_echo_note "bad market (${f_market_performance} < ${GOOD_MARKET_PERFORMANCE_INDEX}) - Price: $current" >>${g_tmp}/output-${tmpfile} 2>&1
|
||||
( check_buy_conditions ${g_tmp}/${tmpfile} "${f_strategy}" 2>&1 || break ) | tee -a ${g_tmp}/output-${tmpfile}
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
@ -88,26 +101,42 @@ function analyze {
|
||||
|
||||
}
|
||||
|
||||
. bot.conf
|
||||
. dabo/dabo-bot.conf
|
||||
. dabo-bot.conf
|
||||
. analyze.conf
|
||||
set | grep ^[A-Z].*=[-0-9]
|
||||
|
||||
cores=$(cat /proc/cpuinfo | grep "^processor.*:" | tail -n1 | perl -pe 's/processor.*: //')
|
||||
echo -n "parallel -j${cores} bash -c --" >/tmp/parallel-$$
|
||||
if [ "${ANALYZE_BATCH}" -eq "0" ]
|
||||
then
|
||||
cores=$(cat /proc/cpuinfo | grep "^processor.*:" | tail -n1 | perl -pe 's/processor.*: //')
|
||||
echo -n "parallel -j${cores} bash -c --" >/tmp/parallel-$$
|
||||
fi
|
||||
|
||||
analyzedate="$(date +%Y-%m-%d--%H-%M-%S)"
|
||||
mkdir "analyze-${analyzedate}"
|
||||
cp bot.conf analyze.conf analyze-${analyzedate}/
|
||||
cp dabo-bot.conf analyze.conf analyze-${analyzedate}/
|
||||
cp -r strategies analyze-${analyzedate}/
|
||||
|
||||
for file in $@
|
||||
do
|
||||
echo "${file}" | grep -q "BALANCE" && continue
|
||||
if [ "${ANALYZE_BATCH}" -eq "0" ]
|
||||
then
|
||||
echo -n " \"analyze ${file}\"" >>/tmp/parallel-$$
|
||||
else
|
||||
analyze ${file}
|
||||
fi
|
||||
done
|
||||
export -f g_echo_note
|
||||
export g_tmp
|
||||
export analyzedate
|
||||
. /tmp/parallel-$$
|
||||
|
||||
if [ "${ANALYZE_BATCH}" -eq "0" ]
|
||||
then
|
||||
export -f g_echo_note
|
||||
export g_tmp
|
||||
export analyzedate
|
||||
. /tmp/parallel-$$
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo "OVERALL RESULT: $(cat ${g_tmp}/overall-result-* | awk '{ SUM += $1 } END { printf("%2.2f", SUM) }')%" | tee analyze-${analyzedate}/overall-result.log
|
||||
cat analyze-${analyzedate}/*.history.csv.log >analyze-${analyzedate}/analyze-overall.log
|
||||
|
Loading…
Reference in New Issue
Block a user