diff --git a/dabo/dabo-bot.conf b/dabo/dabo-bot.conf
index 73d4020..b3b886c 100755
--- a/dabo/dabo-bot.conf
+++ b/dabo/dabo-bot.conf
@@ -10,7 +10,7 @@ STOCK_EXCHANGE="NONE"
FEE="0.5"
# Interval in seconds - Should not be lower then 300
-INTERVAL="900"
+INTERVAL="300"
## Currency used for trading
CURRENCY="USDT"
diff --git a/dabo/dabo-bot.sh b/dabo/dabo-bot.sh
index b6cbfa7..daadc3a 100755
--- a/dabo/dabo-bot.sh
+++ b/dabo/dabo-bot.sh
@@ -17,8 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with dabo. If not, see .
-
-
. /dabo/dabo-prep.sh
### MAIN ###
@@ -31,12 +29,12 @@ export FULL_LOOP=1
echo $0 | grep -q "dabo-bot\.sh" && BOT=1
# cleanup trashlines in asset-histories (possibly generated by kill further of this progress)
-find asset-histories -name "*.csv" -type f | while read csv_file
-do
- csv_timestamp=$(ls --time-style='+%Y%m%d%H%M' -l "${csv_file}" | cut -d" " -f6)
- sed -i "/[0-9]$(date +%Y)-/d" "${csv_file}"
- touch -t ${csv_timestamp} "${csv_file}"
-done
+#find asset-histories -name "*.csv" -type f | while read csv_file
+#do
+# csv_timestamp=$(ls --time-style='+%Y%m%d%H%M' -l "${csv_file}" | cut -d" " -f6)
+# sed -i "/[0-9]$(date +%Y)-/d" "${csv_file}"
+# touch -t ${csv_timestamp} "${csv_file}"
+#done
# run endless loop
@@ -47,7 +45,7 @@ do
then
rm -f firstloop
else
- LOOP_INTERVAL=30 # 60s max free coingecko API interval + 30s puffer
+ LOOP_INTERVAL=30
time_to_interval=$((${LOOP_INTERVAL} - $(date +%s) % ${LOOP_INTERVAL}))
time_to_full_interval=$((${INTERVAL} - $(date +%s) % ${INTERVAL}))
# Check for next general interval
@@ -73,24 +71,25 @@ do
# Timestamp
export f_timestamp=$(g_date_print)
- # get minute interval for find -mmin
- INTERVAL_MIN=$(echo "${INTERVAL}/60-1" | bc -l | sed -r 's/^(-?)\./\10./' | cut -d\. -f1)
- [ -z "${INTERVAL_MIN}" ] && INTERVAL_MIN=1
-
####### TODO -> Funktionen überarbeiten ############
- ### get general market data
- # Get coingecko data
- get_coingecko_data
-
- # Get current MarketData
- get_marketdata
-
- # Check the situation on the market
- if ! market_performance
- then
- f_market_performance=$(cat MARKET_PERFORMANCE_LATEST)
- fi
+#
+# # get minute interval for find -mmin (used by get_marketdata market_performance
+# INTERVAL_MIN=$(echo "${INTERVAL}/60-1" | bc -l | sed -r 's/^(-?)\./\10./' | cut -d\. -f1)
+# [ -z "${INTERVAL_MIN}" ] && INTERVAL_MIN=1
+#
+# ### get general market data
+# # Get coingecko data
+# get_coingecko_data
+#
+# # Get current MarketData
+# get_marketdata
+#
+# # Check the situation on the market
+# if ! market_performance
+# then
+# f_market_performance=$(cat MARKET_PERFORMANCE_LATEST)
+# fi
####### TODO -> Funktionen überarbeiten ENDE ###########
@@ -115,8 +114,8 @@ do
# Get current positions
[ ${FULL_LOOP} = 1 ] && get_positions || continue
- ## Buy something?
- #[ ${FULL_LOOP} = 1 ] && check_for_buy
+ ## Run strategies
+ [ ${FULL_LOOP} = 1 ] && run_strategies
done
diff --git a/dabo/fetch-ohlcv-candles-indicators.sh b/dabo/fetch-ohlcv-candles-indicators.sh
index d1a82ae..fb702a9 100755
--- a/dabo/fetch-ohlcv-candles-indicators.sh
+++ b/dabo/fetch-ohlcv-candles-indicators.sh
@@ -31,12 +31,14 @@ do
# Reload Config
. ../../dabo-bot.conf
. ../../dabo-bot.override.conf
+ # notify failed yahoo downloads
+ [ "$interval" = "1d" ] && cat *USD_* *ECONOMY* 2>/dev/null | notify.sh -s "Failed Yahoo downloads"
# Timestamp
export f_timestamp=$(g_date_print)
# get candles and indicators
get_ohlcv-candles $interval
[ -n "$seconds" ] && sleeptime=$(( ( ($seconds - $(TZ=UTC printf "%(%s)T") % $seconds) % $seconds + 2 )))
- #[[ $interval = 4h ]] &&
+ #[[ $interval = 4h ]] && sleeptime=??
[ "$interval" = "1d" ] && sleeptime=$(($(TZ=UTC date +%s -d "tomorrow 0:00") - $(date +%s) +2 ))
[ "$interval" = "1w" ] && sleeptime=$(($(TZ=UTC date +%s -d "next monday 0:00") - $(date +%s) +2 ))
g_echo_note "Waiting $sleeptime seconds until next run"
diff --git a/dabo/functions/currency_converter.sh b/dabo/functions/currency_converter.sh
index 6ac0114..b67e358 100644
--- a/dabo/functions/currency_converter.sh
+++ b/dabo/functions/currency_converter.sh
@@ -136,7 +136,7 @@ function currency_converter {
return $?
fi
fi
- g_echo_warn "didn't find rate for ${f_currency}-${f_currency_target} - '${FUNCNAME} $@'"
+ g_echo_note "didn't find rate for ${f_currency}-${f_currency_target} - '${FUNCNAME} $@'"
return 1
fi
diff --git a/dabo/functions/get_symbols_ticker.sh b/dabo/functions/get_symbols_ticker.sh
index e5997bc..2a31b9e 100644
--- a/dabo/functions/get_symbols_ticker.sh
+++ b/dabo/functions/get_symbols_ticker.sh
@@ -86,6 +86,7 @@ function get_symbols_ticker {
g_array CCXT_TICKERS-$STOCK_EXCHANGE f_tickers_array_ref
local f_ticker f_symbol f_price
declare -Ag f_tickers_array
+ declare -Ag v
for f_ticker in "${f_tickers_array_ref[@]}"
do
f_symbol=${f_ticker%%:*}
@@ -94,6 +95,7 @@ function get_symbols_ticker {
f_price=${f_ticker/*,/}
g_num_exponential2normal $f_price && f_price=$g_num_exponential2normal_result
f_tickers_array[$f_symbol]=$f_price
+ v[${f_symbol}_price]=$f_price
done
fi
diff --git a/dabo/functions/get_values.sh b/dabo/functions/get_values.sh
index 76676ad..3861c08 100644
--- a/dabo/functions/get_values.sh
+++ b/dabo/functions/get_values.sh
@@ -19,6 +19,7 @@
function get_values {
+ g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
local f_assets="$@"
f_assets=${f_assets//:$CURRENCY/}
@@ -36,11 +37,11 @@ function get_values {
fi
done
- # get current prices
+ # get current prices from exchange
get_symbols_ticker
# get values from csv files
f_first=true
- for f_asset in $f_assets BTC${CURRENCY} $f_eco_assets
+ for f_asset in $f_assets BTC${CURRENCY} $f_eco_assets
do
# read latest ohlcv data and indicators per timeframe to vars
@@ -52,32 +53,51 @@ function get_values {
f_histfile="asset-histories/${f_asset}.history.${f_time}.csv"
if ! [ -s "$f_histfile" ]
then
- g_echo_warn "file $f_histfile emty or does not exist"
+ g_echo_note "file $f_histfile emty or does not exist"
f_return=1
continue
fi
f_columns="${f_prefix}date,${f_prefix}open,${f_prefix}high,${f_prefix}low,${f_prefix}close,${f_prefix}volume,${f_prefix}change,${f_prefix}ath,${f_prefix}ema12,${f_prefix}ema26,${f_prefix}ema50,${f_prefix}ema100,${f_prefix}ema200,${f_prefix}ema400,${f_prefix}ema800,${f_prefix}rsi5,${f_prefix}rsi14,${f_prefix}rsi21,${f_prefix}macd,${f_prefix}macd_ema9_signal,${f_prefix}macd_histogram,${f_prefix}macd_histogram_signal,${f_prefix}macd_histogram_max,${f_prefix}macd_histogram_strength"
- g_read_csv "${f_histfile}" 1 "$f_columns"
+ g_read_csv "${f_histfile}" 2 "$f_columns"
done
- # read current levels and price
- f_levelsfile="asset-histories/${f_asset}.history.csv.levels"
- if [ "$f_first" = "true" ]
- then
- [ -s "$f_levelsfile" ] && v_levels="$(cat "$f_levelsfile")"
- v_price=${f_tickers_array[$f_asset]}
- else
- [ -s "$f_levelsfile" ] && declare -g v_${f_asset}_levels="$(cat "$f_levelsfile")"
- [[ $f_asset =~ ECONOMY ]] || declare -g v_${f_asset}_price="${f_tickers_array[$f_asset]}"
- fi
+ # read current levels
+ #v[${f_asset}_price]=${f_tickers_array[$f_asset]}
+ for f_time in 1w 1d
+ do
+ f_levelsfile="asset-histories/${f_asset}.history.${f_time}.csv.levels"
+ if [ -s "$f_levelsfile" ]
+ then
+ # get levels
+ g_array "$f_levelsfile" f_levels " "
+ v[${f_asset}_levels_$f_time]="${f_levels[*]}"
+
+ # add current price and sort
+ f_levels+=("${v[${f_asset}_price]}")
+ IFS=$'\n' f_levels_sorted=($(sort -n <<<"${f_levels[*]}"))
+
+ # find current price and +- one for upper lower price
+ for ((i=0; i<${#f_levels_sorted[@]}; i++)); do
+ if [ "${f_levels_sorted[$i]}" = "${v[${f_asset}_price]}" ]
+ then
+ v[${f_asset}_levels_${f_time}_next_up]=${f_levels_sorted[i+1]}
+ v[${f_asset}_levels_${f_time}_next_down]=${f_levels_sorted[i-1]}
+ break
+ fi
+ done
+ fi
+ done
unset f_first
done
+ for i in "${!v[@]}"
+ do
+ echo "\${v[$i]}"
+ done | sort >values.new
+ mv values.new values
- set 2>&1 | grep ^v_ | grep -v ^v_csv_array_associative >values
-
return $f_return
}
diff --git a/dabo/functions/strategy.sh b/dabo/functions/run_strategies.sh
similarity index 61%
rename from dabo/functions/strategy.sh
rename to dabo/functions/run_strategies.sh
index f020a6c..4f08442 100644
--- a/dabo/functions/strategy.sh
+++ b/dabo/functions/run_strategies.sh
@@ -18,26 +18,28 @@
# along with dabo. If not, see .
-function strategy {
+function run_strategies {
+
+ g_echo_note "RUNNING FUNCTION ${FUNCNAME} $@"
+
+ local f_strategy
unset s_score
unset s_SYMBOLS
- #find
- #. "${f_strategy}" || return 1
-
- get_values
get_symbols_ticker
+ get_values ${f_symbols_array_trade[*]}
- for f_symbol in "${f_symbols_array_trade[@]}"
+ for f_strategy in $(find /dabo/strategies -type f -name "*strategy*")
do
- echo $f_symbol
- get_values $f_symbol
+ if ! bash -n "${f_strategy}" >$g_tmp/strat_bash_error 2>&1
+ then
+ g_echo_error "Error in ${f_strategy} $(cat $g_tmp/strat_bash_error)"
+ continue
+ fi
+ g_echo_note "Runnign strategy ${f_strategy}"
+ . "${f_strategy}" || g_echo_warn "Failed ${f_strategy}"
done
-
-
- echo "Score: $s_score"
- echo $s_score_hist
}
diff --git a/docker-compose.yml b/docker-compose.yml
index 9bc86e5..f613c8c 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -293,3 +293,5 @@ services:
cpus: '1'
memory: 128M
+
+