From f6960ef9deb701ead9fdb0a1caf0bb24b3694c3a Mon Sep 17 00:00:00 2001 From: olli Date: Tue, 3 Oct 2023 11:05:55 +0200 Subject: [PATCH] fixes if boerse.de is down --- dabo/functions/get_assets.sh | 2 ++ dabo/functions/get_boerse_de.sh | 18 ++++++++++-------- dabo/functions/market_performance.sh | 7 ++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/dabo/functions/get_assets.sh b/dabo/functions/get_assets.sh index 5268b6f..2b372ae 100644 --- a/dabo/functions/get_assets.sh +++ b/dabo/functions/get_assets.sh @@ -132,6 +132,8 @@ function get_assets { get_boerse_de https://www.boerse.de/realtime-kurse/MSCI-World/XC0009692739 MSCI-WORLD-INDEX get_boerse_de https://www.boerse.de/indizes/SundP-500/US78378X1072 SP500-INDEX get_boerse_de https://www.boerse.de/indizes/DJ-AMER-OIL-und-GAS/XC0006886516 OIL-GAS-INDEX + get_boerse_de https://www.boerse.de/fonds/SPDR-SundP-Regional-Banking-ETF/US78464A6982 KRE-BANKING-INDEX + } diff --git a/dabo/functions/get_boerse_de.sh b/dabo/functions/get_boerse_de.sh index b5b789e..ff8fa24 100644 --- a/dabo/functions/get_boerse_de.sh +++ b/dabo/functions/get_boerse_de.sh @@ -2,21 +2,23 @@ function get_boerse_de { local f_url="$1" local f_name="$2" - # get SundP500 Index for analysis + # get data for analysis echo "wget -q -O - ${f_url} | egrep 'itemprop=\"price\" content=\"[0-9]+\.[0-9]+\"' | cut -d\\\" -f6" >BOERSE_DE_CMD - g_runcmd g_retrycmd sh BOERSE_DE_CMD >BOERSE_DE_CMD_OUT.tmp + g_runcmd g_retrycmd sh BOERSE_DE_CMD >BOERSE_DE_CMD_OUT-${f_name}.tmp # check output - if [ -s BOERSE_DE_CMD_OUT.tmp ] && egrep -q "^[0-9]*\.[0-9]+$" BOERSE_DE_CMD_OUT.tmp + if [ -s BOERSE_DE_CMD_OUT-${f_name}.tmp ] && egrep -q "^[0-9]*\.[0-9]+$" BOERSE_DE_CMD_OUT-${f_name}.tmp then - if egrep -q "^0\.00$" BOERSE_DE_CMD_OUT.tmp + if egrep -q "^0\.00$" BOERSE_DE_CMD_OUT-${f_name}.tmp then - g_echo_note "Ignoring ${f_name} $(tail -n 10 BOERSE_DE_CMD_OUT.tmp) - maybe out of business day" + g_echo_note "Ignoring ${f_name} $(tail -n 10 BOERSE_DE_CMD_OUT-${f_name}.tmp) - maybe out of business day" else - mv BOERSE_DE_CMD_OUT.tmp BOERSE_DE_CMD_OUT + g_echo_note "${f_name}: $(tail -n 10 BOERSE_DE_CMD_OUT-${f_name}.tmp)" + mv BOERSE_DE_CMD_OUT-${f_name}.tmp BOERSE_DE_CMD_OUT-${f_name} fi else - g_echo_warn "BOERSE_DE_CMD_OUT.tmp has wrong Syntax. - Not updating ${f_name} Index $(tail -n 10 BOERSE_DE_CMD_OUT.tmp)" + g_echo_warn "BOERSE_DE_CMD_OUT-${f_name}.tmp has wrong Syntax. - Not updating ${f_name} Index $(tail -n 10 BOERSE_DE_CMD_OUT-${f_name}.tmp)" fi - echo "${f_timestamp},$(cat BOERSE_DE_CMD_OUT)" >>asset-histories/${f_name}.history.csv + [ -e "BOERSE_DE_CMD_OUT-${f_name}" ] || echo 0 >BOERSE_DE_CMD_OUT-${f_name} + echo "${f_timestamp},$(cat BOERSE_DE_CMD_OUT-${f_name})" >>asset-histories/${f_name}.history.csv } diff --git a/dabo/functions/market_performance.sh b/dabo/functions/market_performance.sh index 02c7cb8..bcc04c8 100644 --- a/dabo/functions/market_performance.sh +++ b/dabo/functions/market_performance.sh @@ -65,7 +65,12 @@ function market_performance { local f_exchange_rate_diff_percentage=$(g_percentage-diff ${f_from} ${f_to}) #local f_back=10080 #get_rate_percentage_min_before_and_now MSCI-WORLD- INDEX $f_back || return 1 - local f_msci_world_performance=$(echo "scale=2; ${f_exchange_rate_diff_percentage}/2" | bc -l | sed -r 's/^(-?)\./\10./') + if [ ${f_to} == "0" ] || [ ${f_from} == "0" ] + then + local f_msci_world_performance="-0.1" + else + local f_msci_world_performance=$(echo "scale=2; ${f_exchange_rate_diff_percentage}/2" | bc -l | sed -r 's/^(-?)\./\10./') + fi # price performance bitcoin (last 30 minutes) local f_from=$(tail -n 30 asset-histories/BTC${CURRENCY}.history.csv | grep -v ^[A-Z] | head -n1 | cut -d, -f2)