Compare commits
3 Commits
f69d75b1b7
...
655c3b4032
Author | SHA1 | Date | |
---|---|---|---|
655c3b4032 | |||
edfa828c2a | |||
c0a3e85888 |
@ -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
|
||||
|
@ -118,6 +118,9 @@ function get_marketdata_coinmarketcap {
|
||||
else
|
||||
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}"
|
||||
|
||||
}
|
||||
|
||||
@ -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"
|
||||
|
||||
|
@ -54,20 +54,9 @@ 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" ]
|
||||
if [ -n "$LEVERAGE" ]
|
||||
then
|
||||
# do some margin things
|
||||
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user