diff options
Diffstat (limited to 'hledger-allocation')
-rwxr-xr-x | hledger-allocation | 19 |
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 + |