Compare commits

...

3 Commits

Author SHA1 Message Date
655c3b4032 fix exponential number notation 2024-10-21 21:11:27 +02:00
edfa828c2a day fetches 1 minute later 2024-10-21 21:08:36 +02:00
c0a3e85888 fix, calculating amount and leverage 2024-10-21 21:08:12 +02:00
3 changed files with 39 additions and 17 deletions

View File

@ -31,16 +31,20 @@ do
# Reload Config
. ../../dabo-bot.conf
. ../../dabo-bot.override.conf
# notify failed yahoo downloads
[ "$interval" = "1d" ] && cat FAILED_YAHOO/*USD_* FAILED_YAHOO/*ECONOMY* 2>/dev/null | notify.sh -s "Failed Yahoo downloads"
# notify failed downloads
[ "$interval" = "1d" ] && cat FAILED_*/* 2>/dev/null | notify.sh -s "Failed 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 ]] && 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 ))
if [ "$interval" = "1d" ]
then
get_marketdata_fear_and_greed_alternativeme
sleeptime=$(($(TZ=UTC date +%s -d "tomorrow 0:01") - $(date +%s) +2 ))
fi
[ "$interval" = "1w" ] && sleeptime=$(($(TZ=UTC date +%s -d "next monday 0:01") - $(date +%s) +2 ))
g_echo_note "Waiting $sleeptime seconds until next run"
sleep $sleeptime
done

View File

@ -119,6 +119,9 @@ function get_marketdata_coinmarketcap {
egrep -h "^[1-9][0-9][0-9][0-9]-[0-1][0-9]-[0-9][0-9].*,[0-9]" "${f_targetcsvtmp}" | sort -k1,2 -t, -u >"$f_targetcsv"
fi
# change exponential notation to normal notation
g_num_exponential2normal_file "${f_targetcsv}"
}
function get_marketdata_coinmarketcap_ids {
@ -151,7 +154,7 @@ function get_marketdata_coinmarketcap_ids {
f_latest_date_seconds=$(date -d "$f_latest_date" +%s)
if [ $f_latest_date_seconds_now -lt $f_latest_date_seconds ]
then
jq -r '.data | .symbol + "," + (.id|tostring) + "," + .name + "," + (.quotes[].quote|.marketCap|tostring)' "$g_tmp/get_marketdata_coinmarketcap_ids.json" | head -n 1
jq -r '.data | .symbol + "," + (.id|tostring) + "," + .name + "," + (.quotes[].quote|.marketCap|tostring)' "$g_tmp/get_marketdata_coinmarketcap_ids.json" | grep -vi ",0e-" | head -n 1
fi
done | egrep --line-buffered '^.+,[0-9]*,' >"$f_target_loop"

View File

@ -54,17 +54,6 @@ function order {
### validity checks end###
# get amount in crypto asset
if [[ $f_amount =~ ^crypto_amount: ]]
then
# if given in crypto
f_amount=${f_amount//crypto_amount:}
else
# if given in $CURRENCY
local f_asset=${f_symbol///*}
currency_converter $f_amount $CURRENCY $f_asset || return 1
local f_amount=$f_currency_converter_result
fi
# check for swap/margin trades
if [ -n "$LEVERAGE" ]
@ -83,11 +72,37 @@ function order {
# define margibn mode isolated/cross
f_params="${f_params}'marginMode': '$MARGIN_MODE', "
# calculate amount with leverage
g_calc "${f_amount}*${LEVERAGE}"
f_amount=$g_calc_result
else
# short/sell not possible in spot market
[[ $f_side =~ ^sell$ ]] || return 1
fi
# get amount in crypto asset
if [[ $f_amount =~ ^crypto_amount: ]]
then
# if given in crypto
f_amount=${f_amount//crypto_amount:}
else
# on market order use current price
if [[ $f_type = market ]]
then
# if given in $CURRENCY
local f_asset=${f_symbol///*}
currency_converter $f_amount $CURRENCY $f_asset || return 1
f_amount=$f_currency_converter_result
# on limit order use limit price
elif [[ $f_type = limit ]]
then
g_calc "1/${f_price}*${f_amount}"
f_amount=$g_calc_result
fi
fi
# Add stoploos and take profit if available
if [ -n "$f_stoploss" ]
then