do minutely jobs - for alerts, sell conditions,...

This commit is contained in:
olli 2024-01-03 15:58:59 +01:00
parent c37518f0b1
commit 4519d4d4bc

View File

@ -26,6 +26,7 @@ mkdir -p ${BASEPATH}/botdata/trade-histories
cd ${BASEPATH}/botdata
touch firstloop
export FULL_LOOP=1
# am I the bot (important for functions used by analyze.sh
echo $0 | grep -q "dabo-bot\.sh" && BOT=1
@ -38,6 +39,7 @@ do
touch -t ${csv_timestamp} "${csv_file}"
done
# run endless loop
while true
do
@ -46,8 +48,20 @@ do
then
rm -f firstloop
else
g_echo_note "NEXT LOOP - sleping until next full ${INTERVAL} seconds"
sleep $((${INTERVAL} - $(date +%s) % ${INTERVAL}))
LOOP_INTERVAL=60 # 60s max free coinhecko API interval
time_to_interval=$((${LOOP_INTERVAL} - $(date +%s) % ${LOOP_INTERVAL}))
g_echo_note "NEXT LOOP - sleeping ${time_to_interval} seconds until next full ${LOOP_INTERVAL} seconds"
sleep ${time_to_interval}
# Check for next general interval
time_to_full_interval=$((${INTERVAL} - $(date +%s) % ${INTERVAL}))
if [ ${time_to_full_interval} -le ${time_to_interval} ]
then
g_echo_note "NEXT FULL LOOP NOW - all ${INTERVAL} seconds"
FULL_LOOP=1
else
g_echo_note "NEXT FULL LOOP - ${INTERVAL} seconds in ${time_to_full_interval} seconds"
FULL_LOOP=0
fi
fi
# reload config
@ -78,9 +92,15 @@ do
TRADE_CMD='bitpanda-api-call POST public/v1/account/orders "--header \"Content-Type: application/json\" --data \"{\\\"instrument_code\\\":\\\"TOKEN\\\",\\\"side\\\":\\\"ACTION\\\",\\\"type\\\":\\\"MARKET\\\",\\\"amount\\\":\\\"QUANTITY\\\"}\""'
fi
# Get coingecko data
get_coingecko_data
# Get current assets
get_assets || continue
# stop here if no full loop
[ ${FULL_LOOP} == 0 ] && continue
# Get current balances
get_balances || continue