From 57b6271251f343b49351883090a3b1955ba0ddae Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 22 May 2021 06:03:07 -0400 Subject: add hledger-allocation --- hledger-allocation | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 hledger-allocation 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 + -- cgit v1.2.3