Last active
December 18, 2020 02:12
-
-
Save timcappalli/80eaebcd814fa06c46886fe242e69f1a to your computer and use it in GitHub Desktop.
Bitbar - crypto
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
#!/bin/bash | |
# <bitbar.title>Bitso buys price</bitbar.title> | |
# <bitbar.version>v1.0</bitbar.version> | |
# <bitbar.author>Erick Madrid</bitbar.author> | |
# <bitbar.author.github>Neovirxp</bitbar.author.github> | |
# <bitbar.desc>Displays Bitso buy prices of Bitcoin, Ethereum, Ripple in USD</bitbar.desc> | |
# <bitbar.image>https://image.ibb.co/h9mWFG/Screen_Shot_2017_11_28_at_7_59_08_PM.png</bitbar.image> | |
# <bitbar.dependencies>bash, jq</bitbar.dependencies> | |
# If you feel this little tool gives you some value, tips are always welcome at the following addresses! | |
# Bitcoin: 19sFQuSb1cwGA9Cb5XYVMHeYUVW8ME6ki8 | |
# Ethereum: 0xF8D3C6dd50536eC8FF61CCE5C47F8191f55c9B81 | |
export LANG='en_US.UTF-8' | |
export LC_NUMERIC='en_US' | |
export PATH="/usr/local/bin/:$PATH" | |
source /Users/Shared/Bitbar/bitbar-crypto-last-btc.txt | |
source /Users/Shared/Bitbar/bitbar-crypto-last-eth.txt | |
BTC_LAST=$(echo $lastbtc | cut -d "." -f 1 | cut -d "," -f 1) | |
ETH_LAST=$(echo $lasteth | cut -d "." -f 1 | cut -d "," -f 1) | |
BTC_USD=$(curl -s 'https://api.bitso.com/v3/ticker/?book=btc_usd') | |
ETH_USD=$(curl -s 'https://api.bitso.com/v3/ticker/?book=eth_usd') | |
BTC_NOW=$(echo "$BTC_USD" | jq '.payload.last' | tr -d \") | |
ETH_NOW=$(echo "$ETH_USD" | jq '.payload.last' | tr -d \") | |
BTC_DIFF=$(echo "$BTC_NOW - $BTC_LAST" | bc ) | |
ETH_DIFF=$(echo "$ETH_NOW - $ETH_LAST" | bc ) | |
printf "BTC: $%'.0f d$%'.0f | color=white \n" "$BTC_NOW" "$BTC_DIFF" | |
printf "ETH: $%'.0f d$%'.0f | color=white \n" "$ETH_NOW" "$ETH_DIFF" | |
echo "lastbtc=$BTC_NOW" > /Users/Shared/Bitbar/bitbar-crypto-last-btc.txt | |
echo "lasteth=$ETH_NOW" > /Users/Shared/Bitbar/bitbar-crypto-last-eth.txt | |
echo '---' | |
echo "$BTC_NOW" | xargs printf "1 BTC = %'.2f USD | color=green \n" | |
echo '---' | |
# last 24 hours price high | |
echo "$BTC_USD" | jq '.payload.high' | tr -d \" | xargs printf "HIGH\t$%'.2f USD\n" | |
# last 24 hours price low | |
echo "$BTC_USD" | jq '.payload.low' | tr -d \" | xargs printf "LOW \t$%'.2f USD\n" | |
echo '---' | |
# lowest sell order | |
echo "$BTC_USD" | jq '.payload.ask' | tr -d \" | xargs printf "ASK\t\t$%'.2f USD\n" | |
# highest buy order | |
echo "$BTC_USD" | jq '.payload.bid' | tr -d \" | xargs printf "BID\t\t$%'.2f USD\n" | |
echo '---' | |
echo "$ETH_NOW" | xargs printf "1 ETH = %'.2f USD | color=blue \n" | |
echo '---' | |
# last 24 hours price high | |
echo "$ETH_USD" | jq '.payload.high' | tr -d \" | xargs printf "HIGH\t$%'.2f USD\n" | |
# last 24 hours price low | |
echo "$ETH_USD" | jq '.payload.low' | tr -d \" | xargs printf "LOW \t$%'.2f USD\n" | |
echo '---' | |
# lowest sell order | |
echo "$ETH_USD" | jq '.payload.ask' | tr -d \" | xargs printf "ASK\t\t$%'.2f USD\n" | |
# highest buy order | |
echo "$ETH_USD" | jq '.payload.bid' | tr -d \" | xargs printf "BID\t\t$%'.2f USD\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment