diff --git a/dabo/functions/get_marketdata.sh b/dabo/functions/get_marketdata.sh index 8a3f05a..9b80924 100644 --- a/dabo/functions/get_marketdata.sh +++ b/dabo/functions/get_marketdata.sh @@ -33,6 +33,8 @@ function get_marketdata { #get_marketdata_from_url https://www.investing.com/economic-calendar/unemployment-rate-300/ US-UNEMPLOYMENT-INDEX #get_marketdata_from_url https://www.investing.com/economic-calendar/cpi-733 US-CONSUMER-PRICE-INDEX #get_marketdata_from_url https://www.investing.com/indices/fed-funds-composite-interest-rate-opinion US-FED-FEDERAL-FUNDS-RATE-INVERTED-INDEX + get_marketdata_from_url '"https://fapi.binance.com/futures/data/globalLongShortAccountRatio?symbol=BTCUSDT&period=5m" | jq -r .[].longShortRatio | tail -n1' BINANCE-GlobalLongShortAccountRatio + get_marketdata_from_url '"https://fapi.binance.com/futures/data/takerlongshortRatio?symbol=BTCUSDT&period=5m" | jq -r .[].buySellRatio | tail -n1' BINANCE-TakerLongShortRatio # clear old stuff find asset-histories/*INDEX* -type f -mtime +6 -delete } @@ -51,11 +53,22 @@ function get_marketdata_from_url { # check source platform for parsing parameters, prepare and run wget command >MARKET_DATA_CMD - echo ${f_url} | grep -q "boerse.de" && echo "wget ${g_wget_opts} -q -O - ${f_url} | egrep 'itemprop=\"price\" content=\"[0-9]+\.[0-9]+\"' | sed s'#\"#\n#g' | egrep '^[0-9]+\.[0-9]+'" >MARKET_DATA_CMD - echo ${f_url} | egrep -q "investing.com.+economic-calendar" && echo "wget ${g_wget_opts} -q -O - ${f_url} | egrep 'Actual.+Forecast.+Previous' | cut -d'>' -f7,11 | cut -d'<' -f1,2 | sed 's#,##g' | sed 's/\%//g' | sed 's##,#' | grep '[0-9]'" >MARKET_DATA_CMD - echo ${f_url} | egrep -q "investing.com.+indices" && echo "wget ${g_wget_opts} -q -O - ${f_url} | sed 's##\n#g' | grep 'text-5xl.*font-bold.*md:text-' | sed 's#^.*>##; s#,##g' | grep '[0-9]'" >MARKET_DATA_CMD + if echo "${f_url}" | grep -q "boerse.de" + then + echo "wget ${g_wget_opts} -q -O - ${f_url} | egrep 'itemprop=\"price\" content=\"[0-9]+\.[0-9]+\"' | sed s'#\"#\n#g' | egrep '^[0-9]+\.[0-9]+'" >MARKET_DATA_CMD + elif echo "${f_url}" | egrep -q "investing.com.+economic-calendar" + then + echo "wget ${g_wget_opts} -q -O - ${f_url} | egrep 'Actual.+Forecast.+Previous' | cut -d'>' -f7,11 | cut -d'<' -f1,2 | sed 's#,##g' | sed 's/\%//g' | sed 's##,#' | grep '[0-9]' | cut -d, -f1" >MARKET_DATA_CMD + elif echo "${f_url}" | egrep -q "investing.com.+indices" + then + echo "wget ${g_wget_opts} -q -O - ${f_url} | sed 's##\n#g' | grep 'text-5xl.*font-bold.*md:text-' | sed 's#^.*>##; s#,##g' | grep '[0-9]'" >MARKET_DATA_CMD + elif echo "${f_url}" | egrep -q '^"https://' + then + echo "wget -q -O - ${g_wget_opts} ${f_url}" >MARKET_DATA_CMD + else # default to Yahoo Finace Symbols via API - [ -s MARKET_DATA_CMD ] || echo "wget ${g_wget_opts} -q -O - https://query1.finance.yahoo.com/v8/finance/chart/${f_url} | jq -r '.[].result[].meta.regularMarketPrice'" >MARKET_DATA_CMD + echo "wget ${g_wget_opts} -q -O - https://query1.finance.yahoo.com/v8/finance/chart/${f_url} | jq -r '.[].result[].meta.regularMarketPrice'" >MARKET_DATA_CMD + fi g_runcmd g_retrycmd sh MARKET_DATA_CMD >MARKET_DATA_CMD_OUT-${f_name}.tmp 2>MARKET_DATA_CMD_OUT-${f_name}.tmp.err