git.slaskete.net
/
einar-bin
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
8cd946f
)
Fix broken zec.sh
author
Einar Jørgen Haraldseid
<einar@haraldseid.net>
Thu, 14 Jul 2022 16:26:23 +0000
(18:26 +0200)
committer
Einar Jørgen Haraldseid
<einar@haraldseid.net>
Thu, 14 Jul 2022 16:26:23 +0000
(18:26 +0200)
zec.sh
patch
|
blob
|
history
diff --git
a/zec.sh
b/zec.sh
index 75d7c9412391d53fa143f2e85736e30da8537bdd..d0733006d650db18c1327ffa430aeea48c8b7e9d 100755
(executable)
--- a/
zec.sh
+++ b/
zec.sh
@@
-2,8
+2,8
@@
LC_NUMERIC="en_US.utf-8"
CacheFile="/tmp/coinindex.json"
CacheFile2="/tmp/usd-nok.csv"
LC_NUMERIC="en_US.utf-8"
CacheFile="/tmp/coinindex.json"
CacheFile2="/tmp/usd-nok.csv"
-ApiURL="https://www.worldcoinindex.com/apiservice/json?key=
iOU8ko9QJ01Qj1JXoXfAXaoLD
"
-ApiURL2="https://data.norges-bank.no/api/data/EXR/B.
NOK.USD
.SP.A?lastNObservations=1&format=csv-:-tab-false-y"
+ApiURL="https://www.worldcoinindex.com/apiservice/json?key=
srko6KyVB4VgtbfKsCKQibWe7Y6rjEcgN93
"
+ApiURL2="https://data.norges-bank.no/api/data/EXR/B.
USD.NOK
.SP.A?lastNObservations=1&format=csv-:-tab-false-y"
CacheTime="150" # 150 seconds = 2.5 minutes
NumberRegex="^[0-9]+([.][0-9]+)?$"
CacheTime="150" # 150 seconds = 2.5 minutes
NumberRegex="^[0-9]+([.][0-9]+)?$"
@@
-31,10
+31,16
@@
fi
PriceZECinUSD="$(jq '.Markets | .[] | select(.Name=="Zcash") | .Price_usd' ${CacheFile})"
PriceUSDinNOK="$(tail -n 1 ${CacheFile2} | cut -f 2 | tr -d \")"
PriceZECinNOK="$(echo "${PriceZECinUSD}*${PriceUSDinNOK}" | bc)"
PriceZECinUSD="$(jq '.Markets | .[] | select(.Name=="Zcash") | .Price_usd' ${CacheFile})"
PriceUSDinNOK="$(tail -n 1 ${CacheFile2} | cut -f 2 | tr -d \")"
PriceZECinNOK="$(echo "${PriceZECinUSD}*${PriceUSDinNOK}" | bc)"
+PriceZECinUSDPretty="$(printf "%0.2f\n" $PriceZECinUSD)"
+PriceZECinNOKPretty="$(printf "%0.2f\n" $PriceZECinNOK)"
ValueUSD="$(echo "${PriceZECinUSD}*${Value}" | bc | sed 's/^\./0./')"
ValueNOK="$(echo "${PriceZECinNOK}*${Value}" | bc | sed 's/^\./0./')"
ValueUSDPretty="$(printf "%0.4f\n" $ValueUSD)"
ValueNOKPretty="$(printf "%0.4f\n" $ValueNOK)"
ValueUSD="$(echo "${PriceZECinUSD}*${Value}" | bc | sed 's/^\./0./')"
ValueNOK="$(echo "${PriceZECinNOK}*${Value}" | bc | sed 's/^\./0./')"
ValueUSDPretty="$(printf "%0.4f\n" $ValueUSD)"
ValueNOKPretty="$(printf "%0.4f\n" $ValueNOK)"
-echo "${Value} ZEC = \$ ${ValueUSDPretty} (about NOK ${ValueNOKPretty})"
+if [ -z ${1+x} ]; then
+ echo "${Value} ZEC = \$ ${ValueUSDPretty} (about NOK ${ValueNOKPretty})"
+else
+ echo "${Value} ZEC = \$ ${ValueUSDPretty} (about NOK ${ValueNOKPretty}) (1 ZEC = \$ ${PriceZECinUSDPretty} / NOK ${PriceZECinNOKPretty})"
+fi