Tickers color scheme

This commit is contained in:
2025-01-18 10:55:50 -05:00
parent 5c098bd26d
commit 6f8c0b08d7
9 changed files with 48 additions and 46 deletions

View File

@@ -1,3 +1,5 @@
#!/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
@@ -6,31 +8,31 @@ if [ "$1" = "BTCUSDC" ]; then
else
price=$(echo "$raw" | jq -r ".result.$1.b[0]")
fi
# echo "$price"
#if (( $(echo "$price < 1" | bc -l) )); then
#if [ $(echo "$price < 1" | bc -l) -eq 1 ]; then
#printf "%0.3f\n" "$price" | cut -c 3-
#elif (( $(echo "$price < 10" | bc -l) )); then
#elif [ $(echo "$price < 10" | bc -l) -eq 1 ]; then
#printf "%0.3f\n" "$price" | cut -c 3-
#elif (( $(echo "$price < 1000" | bc -l) )); then
#printf "%'0.1f\n" "$price" | sed 's/,//'
#elif (( $(echo "$price < 10000" | bc -l) )); then
#printf "%'0.0f\n" "$price" | sed 's/,//'
#elif (( $(echo "$price > 100000" | bc -l) )); then
#printf "%'0.0f\n" "$price" | sed 's/,//' | cut -c -4
#else
#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) -eq 1 ]; then
if (( $(echo "$price < 1" | bc -l) )); then
printf "%0.3f\n" "$price" | cut -c 3-
elif [ $(echo "$price < 10" | bc -l) -eq 1 ]; then
elif (( $(echo "$price < 10" | bc -l) )); then
printf "%0.3f\n" "$price" | cut -c 3-
elif [ $(echo "$price < 100" | bc -l) -eq 1 ]; then
elif (( $(echo "$price < 100" | bc -l) )); then
echo "$price" | numfmt --grouping | cut -c -2
elif [ $(echo "$price < 1000" | bc -l) -eq 1 ]; then
elif (( $(echo "$price < 1000" | bc -l) )); then
echo "$price" | numfmt --grouping | cut -c -3
elif [ $(echo "$price < 10000" | bc -l) -eq 1 ]; then
echo "$price" | numfmt --grouping
elif [ $(echo "$price > 100000" | bc -l) -eq 1 ]; then
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