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"