PV aliases, fix Kraken script for BTC

This commit is contained in:
2023-07-11 04:58:33 -04:00
parent 1afe9d05a4
commit 436a7cbb87
8 changed files with 102 additions and 32 deletions

View File

@@ -1,8 +1,17 @@
price=$(curl -s "https://api.kraken.com/0/public/Ticker?pair=$1" | jq -r ".result.$1.b[0]")
# echo $price
# price=$(curl -s "https://api.kraken.com/0/public/Ticker?pair=$1" | jq -r ".result.$1.b[0]")
raw=$(curl -s "https://api.kraken.com/0/public/Ticker?pair=$1")
# echo $raw
if [ "$1" = "BTCUSDC" ]; then
price=$(echo "$raw" | jq -r ".result.XBTUSDC.b[0]")
else
price=$(echo "$raw" | jq -r ".result.$1.b[0]")
fi
# echo "$price"
if (( $(echo "$price < 10" | bc -l) )); then
printf "%0.3f\n" "$price" | cut -c 3-
# printf "%0.3f\n" "$price"
elif (( $(echo "$price < 10000" | bc -l) )); then
printf "%'0.0f\n" "$price" | sed 's/,//'
else
echo "$price" | cut -c -3
fi