From 16bb308c4b5105806b5bbd896d8733d3d03d7d32 Mon Sep 17 00:00:00 2001 From: olli Date: Thu, 17 Oct 2024 17:04:45 +0200 Subject: [PATCH] add marketcap to ID-file ; if multiple items use the one with largest marketcap --- dabo/functions/get_marketdata_coinmarketcap.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dabo/functions/get_marketdata_coinmarketcap.sh b/dabo/functions/get_marketdata_coinmarketcap.sh index add0d07..9067e1b 100644 --- a/dabo/functions/get_marketdata_coinmarketcap.sh +++ b/dabo/functions/get_marketdata_coinmarketcap.sh @@ -60,14 +60,11 @@ function get_marketdata_coinmarketcap { then # remove /* f_item=${f_item///*/} - ## remove :* (for example :USDT in contract markets) - #f_item=${f_item//:*} - # remove spaces - #f_item=${f_item/ /} fi local f_id - f_id=$(egrep "^${f_item},[1-9]" COINMARKETCAPIDS | head -n1 | cut -d, -f2) + # get id -> If multiple take the one with the largest marketcap + f_id=$(egrep "^${f_item},[1-9]" COINMARKETCAPIDS | sort -n -t, -k4 | tail -n1 | cut -d, -f2) [[ $f_item = EURC ]] && f_id=20641 if [ -z "$f_id" ] then @@ -155,8 +152,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 '.[] | .symbol + "," + (.id|tostring) + "," + .name' "$g_tmp/get_marketdata_coinmarketcap_ids.json" | head -n 1 - # jq -r '.[] | .symbol + "," + (.id|tostring) + "," + .name' "$g_tmp/get_marketdata_coinmarketcap_ids.json" | head -n 1 1>&2 + jq -r '.data | .symbol + "," + (.id|tostring) + "," + .name + "," + (.quotes[].quote|.marketCap|tostring)' "$g_tmp/get_marketdata_coinmarketcap_ids.json" | head -n 1 fi done | egrep --line-buffered '^.+,[0-9]*,' >"$f_target_loop"