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 | |
parent | 8749935f4be2d685b6a77d8e31d4ce91726c12a3 (diff) |
update bitcoin allocation and bal scripts
-rwxr-xr-x | bitcoin-bal | 15 | ||||
-rwxr-xr-x | hledger-allocation | 3 |
2 files changed, 12 insertions, 6 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 diff --git a/hledger-allocation b/hledger-allocation index 87a6541..53a8371 100755 --- a/hledger-allocation +++ b/hledger-allocation @@ -9,7 +9,7 @@ networth=$(hledger bal ^as ^li --value=now,USD --output-format=csv \ | tr -d [totalUSD,\"]) #commodities=$(hledger commodities) -commodities=("BTC|sat|GBTC" GROQ USD ETH BCH LTC XLM) +commodities=("BTC|sat|SAT|GBTC" GROQ USD ETH BCH LTC XLM) printf "networth: %.2f USD\n\n" $networth @@ -19,4 +19,3 @@ do pct=$(bc -l <<< "$n/$networth*100") printf "%s: %.1f%%\n" $com $pct done - |