summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-05-22 06:03:07 -0400
committerBen Sima <ben@bsima.me>2021-05-22 06:03:11 -0400
commit57b6271251f343b49351883090a3b1955ba0ddae (patch)
treea6ccf7f66d208a3794a5a8764680ad72c50ab994
parent622f1dcb284952df4619917a825d292793920acd (diff)
add hledger-allocation
-rwxr-xr-xhledger-allocation19
1 files changed, 19 insertions, 0 deletions
diff --git a/hledger-allocation b/hledger-allocation
new file mode 100755
index 0000000..e706ba2
--- /dev/null
+++ b/hledger-allocation
@@ -0,0 +1,19 @@
+
+alias cleanup="tail -n1 | tr -d [:alpha:] | tr -d [:blank:] | tr -d [=,=]"
+
+networth=$(hledger bal ^as ^li --value=now,USD --output-format=csv \
+ | tail -n1 \
+ | tr -d [totalUSD,\"])
+
+#commodities=$(hledger commodities)
+commodities=("BTC|sat|GBTC" GROQ USD ETH BCH LTC XLM)
+
+printf "networth: %.2f USD\n\n" $networth
+
+for com in ${commodities[@]}
+do
+ n=$(hledger bal ^as ^li cur:"$com" --value=now,USD | cleanup)
+ pct=$(bc -l <<< "$n/$networth*100")
+ printf "%s: %.1f%%\n" $com $pct
+done
+