You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.6 KiB
39 lines
1.6 KiB
#!/bin/bash
|
|
|
|
# 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
|
|
#if [ $(echo "$price < 1" | bc -l) -eq 1 ]; then
|
|
#printf "%0.3f\n" "$price" | cut -c 3-
|
|
#elif [ $(echo "$price < 10" | bc -l) -eq 1 ]; then
|
|
#printf "%0.3f\n" "$price" | cut -c 3-
|
|
#elif [ $(echo "$price < 100" | bc -l) -eq 1 ]; then
|
|
#echo "$price" | numfmt --grouping | cut -c -2
|
|
#elif [ $(echo "$price < 1000" | bc -l) -eq 1 ]; then
|
|
#echo "$price" | numfmt --grouping | cut -c -3
|
|
#elif [ $(echo "$price < 10000" | bc -l) -eq 1 ]; then
|
|
##echo "$price" | numfmt --grouping | cut -c -3
|
|
#echo "$price" | cut -c -3
|
|
#elif [ $(echo "$price > 100000" | bc -l) -eq 1 ]; then
|
|
#echo "$price" | numfmt --grouping | cut -c -3
|
|
#fi
|
|
|
|
if (( $(echo "$price < 1" | bc -l) )); then
|
|
printf "%0.3f\n" "$price" | cut -c 3-
|
|
elif (( $(echo "$price < 10" | bc -l) )); then
|
|
printf "%0.3f\n" "$price" | cut -c 3-
|
|
elif (( $(echo "$price < 100" | bc -l) )); then
|
|
#echo "$price" | numfmt --grouping | cut -c -2
|
|
echo "$price" | tr -d '.' | awk '{print substr($0, 1, 3)}'
|
|
elif (( $(echo "$price < 1000" | bc -l) )); then
|
|
echo "$price" | numfmt --grouping | cut -c -3
|
|
elif (( $(echo "$price < 10000" | bc -l) )); then
|
|
echo "$price" | cut -c -3
|
|
elif (( $(echo "$price > 100000" | bc -l) )); then
|
|
echo "$price" | numfmt --grouping | cut -c -3
|
|
fi
|