Skip to content

Instantly share code, notes, and snippets.

@shrwnsan
Last active August 15, 2017 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrwnsan/540ba32d0952b0f517a25f6271b863c3 to your computer and use it in GitHub Desktop.
Save shrwnsan/540ba32d0952b0f517a25f6271b863c3 to your computer and use it in GitHub Desktop.
Coins.ph BTC rate tracker. This was actually from a gifted colleague of mine. Did some UX improvements =)
#!/bin/bash
AS_OF_DATE=$(date "+%Y-%m-%d %H:%M")
RESULT=$(curl -s https://quote.coins.ph/v1/markets/BTC-PHP | /usr/local/bin/jq -r '.market.bid,.market.ask')
BID=$(echo $RESULT | sed 's/ /-/g' | cut -f1 -d-)
ASK=$(echo $RESULT | sed 's/ /-/g' | cut -f2 -d-)
USD=$(echo "scale=2; $ASK/50" | bc)
echo "$AS_OF_DATE => $BID - $ASK (\$$USD)"
if [ $ASK -lt 200000 ]
then
osascript -e "display notification \"Bid: $BID\nAsk: $ASK\" with title \"As of $AS_OF_DATE\""
fi
* * * * * . ~/coins-btc-tracker.sh >> ~/coins-btc-tracker.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment