summaryrefslogtreecommitdiff
path: root/hledger-allocation
blob: 077e1b8337ef39461873606f681d23827b2dbef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash

function cleanup() {
    tail -n1 $1 | tr -d [:alpha:] | tr -d [:blank:] | tr -d [=,=]
}

networth=$(hledger bal ^as ^li --value=now,USD --auto --output-format=csv \
  | tail -n1 \
  | tr -d [totalUSD,\"])

#commodities=$(hledger commodities)
commodities=("BTC|sat|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