Skip to content

Instantly share code, notes, and snippets.

@rnkn
Last active October 6, 2021 16:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnkn/e12949b099437ed1d20bd4fb8681141a to your computer and use it in GitHub Desktop.
Save rnkn/e12949b099437ed1d20bd4fb8681141a to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
eval $(/usr/libexec/path_helper)
source "${HOME}/.bashrc"
red=$(tput setaf 1)
green=$(tput setaf 2)
reset="\e[0m"
DATA=$(curl --silent https://api.bitfinex.com/v1/pubticker/btcusd)
HIGH=$(echo $DATA | jq ".high" | tr -d \")
LOW=$(echo $DATA | jq ".low" | tr -d \")
BID=$(echo $DATA | jq ".bid" | tr -d \")
ASK=$(echo $DATA | jq ".ask" | tr -d \")
BFXCUR=$(echo $DATA | jq ".last_price" | tr -d \")
VOL=$(echo $DATA | jq ".volume" | tr -d \")
FIAT="USD"
printf "Bitfinex:BTCUSD"
printf "\n${green}%-8s%'.2f ${FIAT}${reset}" "Bid:" "$BID"
printf "\n${red}%-8s%'.2f ${FIAT}${reset}" "Ask:" "$ASK"
printf "\n%-8s%'.2f ${FIAT}" "Spread:" $(echo "$ASK - $BID" | bc -l)
printf "\n%-8s%'.2f ${FIAT}" "Last:" "$BFXCUR"
printf "\n%-8s%'.2f BTC\n %'.2f ${FIAT}" "Volume:" "$VOL" $(echo "$VOL * $BFXCUR" | bc -l)
DATA=$(curl --silent https://api.btcmarkets.net/market/BTC/AUD/tick)
BID=$(echo $DATA | jq ".bestBid" | tr -d \")
ASK=$(echo $DATA | jq ".bestAsk" | tr -d \")
BTMCUR=$(echo $DATA | jq ".lastPrice" | tr -d \")
VOL=$(echo $DATA | jq ".volume24h" | tr -d \")
FIAT="AUD"
printf "\n\nBTCMarkets:BTCAUD"
printf "\n${green}%-8s%'.2f ${FIAT}${reset}" "Bid:" "$BID"
printf "\n${red}%-8s%'.2f ${FIAT}${reset}" "Ask:" "$ASK"
printf "\n%-8s%'.2f ${FIAT}" "Spread:" $(echo "$ASK - $BID" | bc -l)
printf "\n%-8s%'.2f ${FIAT}" "Last:" "$BTMCUR"
printf "\n%-8s%'.2f BTC\n %'.2f ${FIAT}" "Volume:" "$VOL" $(echo "$VOL * $BTMCUR" | bc -l)
DATA=$(curl --silent http://api.fixer.io/latest?base=AUD)
AUDUSD=$(echo $DATA | jq ".rates.USD")
BTCX=$(echo "$BFXCUR / $BTMCUR" | bc -l | sed "s/^\./0./")
printf "\n\n%-8s%.4f USD" "AUD:" "$AUDUSD"
printf "\n%-8s%.4f (%.2f%%)\n" "Xrate:" "$BTCX" $(echo "$BTCX / $AUDUSD * 100" | bc -l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment