add marketcap to ID-file ; if multiple items use the one with largest marketcap

This commit is contained in:
olli 2024-10-17 17:04:45 +02:00
parent d1805e5fc4
commit 16bb308c4b

View File

@ -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"