Skip to content

Instantly share code, notes, and snippets.

@stinethebean3
Created January 31, 2018 06:47
Show Gist options
  • Select an option

  • Save stinethebean3/98ea4475e66ce4cbbccc2bb7555cf962 to your computer and use it in GitHub Desktop.

Select an option

Save stinethebean3/98ea4475e66ce4cbbccc2bb7555cf962 to your computer and use it in GitHub Desktop.
Let's you know if Bitcoin is at an all time high (ath) or not
#!/bin/bash
ath_api="https://api.coindesk.com/v1/bpi/historical/close.json"
ath_args="?start=2013-01-01&end=$(date '+%Y-%m-%d')"
ath=$(\
curl -s ${ath_api}${ath_args} | \
jq '.bpi| to_entries[] | .value' | \
sort -nr | \
head -n 1
)
price_api="https://api.coinbase.com/v2/prices/spot?currency=USD"
current=$(\
curl -s ${price_api} | \
jq -r '.data .amount'
)
echo "All time high: \$${ath}"
echo "Current price: \$${current}"
if (( $(echo "$current > $ath" | bc -l) )); then
echo "To the moon!!"
else
echo "Keep hodling"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment