summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbitcoin-bal15
-rwxr-xr-xhledger-allocation3
2 files changed, 12 insertions, 6 deletions
diff --git a/bitcoin-bal b/bitcoin-bal
index 11331a6..78e9a31 100755
--- a/bitcoin-bal
+++ b/bitcoin-bal
@@ -1,5 +1,12 @@
#!/usr/bin/env bash
-btc=$(hledger bal cur:BTC ^as | tail -n1 | tr -d ' BTC')
-usd=$(hledger bal cur:BTC ^as -V | tail -n1 | tr -d ' USD')
-echo "$btc BTC"
-echo "$usd USD"
+btc=$(hledger bal cur:"BTC|sat" ^as --value=now,BTC \
+ | tail -n1 | tr -d ' BTC')
+cost=$(hledger bal cur:"BTC|sat" ^as --value=cost,USD \
+ | tail -n1 | tr -d ' USD')
+usd=$(hledger bal cur:"BTC|sat" ^as --value=now,USD \
+ | tail -n1 | tr -d ' USD')
+roi=$(bc -l <<< "100 * $(tr -d ',' <<< "$usd") / $(tr -d ',' <<< "$cost")")
+echo " btc: $btc BTC"
+echo " usd: $usd USD"
+echo "cost: $cost USD"
+printf " roi: %.2f%%\n" $roi
diff --git a/hledger-allocation b/hledger-allocation
index 87a6541..53a8371 100755
--- a/hledger-allocation
+++ b/hledger-allocation
@@ -9,7 +9,7 @@ networth=$(hledger bal ^as ^li --value=now,USD --output-format=csv \
| tr -d [totalUSD,\"])
#commodities=$(hledger commodities)
-commodities=("BTC|sat|GBTC" GROQ USD ETH BCH LTC XLM)
+commodities=("BTC|sat|SAT|GBTC" GROQ USD ETH BCH LTC XLM)
printf "networth: %.2f USD\n\n" $networth
@@ -19,4 +19,3 @@ do
pct=$(bc -l <<< "$n/$networth*100")
printf "%s: %.1f%%\n" $com $pct
done
-