stechico
7/28/2017 - 4:16 AM

Coins.ph BTC rate tracker. This was actually from a gifted colleague of mine. Did some UX improvements =)

Coins.ph BTC rate tracker. This was actually from a gifted colleague of mine. Did some UX improvements =)

* * * * * . ~/coins-btc-tracker.sh >> ~/coins-btc-tracker.log 2>&1
#!/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