Created
September 4, 2020 01:45
-
-
Save soundslikeinfo/84e451efc0a9235c212d9c301e526578 to your computer and use it in GitHub Desktop.
Output a chart of crypto value and percent change in the last 1h, 24h, 7d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function echocryptonumbers { | |
printf ' %-5s: %21s %7s %10s %9s\n' "COIN" "CURRENT VALUE" "1H" "24H" "7D" | |
# echo -e "Coin : Current Value 1h 24h 7d" | |
curl -s -H 'X-CMC_PRO_API_KEY: {CMC_PRO_API_KEY}' \ | |
-H 'Accept: application/json' \ | |
-d 'symbol=BTC,ETH,LTC' \ | |
-G https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest | \ | |
jq -r '.data | .[] | .symbol, .quote.USD.price, .quote.USD.percent_change_1h, .quote.USD.percent_change_24h, .quote.USD.percent_change_7d' | \ | |
while read -r SYMBOL; do | |
read -r PRICE | |
read -r PERCENT_CHANGE_1H | |
read -r PERCENT_CHANGE_24H | |
read -r PERCENT_CHANGE_7D | |
printf ' %-5s: $%21.14f | %6.2f %% %6.2f %% %6.2f %%\n' "${SYMBOL}" "${PRICE}" "${PERCENT_CHANGE_1H}" "${PERCENT_CHANGE_24H}" "${PERCENT_CHANGE_7D}" | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment