diff options
author | Ben Sima <ben@bsima.me> | 2021-12-16 09:21:04 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-12-16 09:21:04 -0500 |
commit | 9982ab07463ceaf6e885c60bac1dd36296bc699a (patch) | |
tree | 98586fcf4ff2ecfad1787c1f70cd71fc0717ee9a /bitcoin-bal | |
parent | 8749935f4be2d685b6a77d8e31d4ce91726c12a3 (diff) |
update bitcoin allocation and bal scripts
Diffstat (limited to 'bitcoin-bal')
-rwxr-xr-x | bitcoin-bal | 15 |
1 files changed, 11 insertions, 4 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 |