Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ~$ cat bin/quotes
- #!/bin/sh
- curl -s https://ca.finance.yahoo.com/quote/BTC-CAD/ | grep -Po '(currency\W{3}CAD\W{3}regularMarketPrice\W{4}raw\W{2})([\d\.]+)(\W{2}fmt)' | cut -d":" -f 4 | cut -d"," -f 1 | tail -1 | sed 's/^/BTC /'
- curl -s https://ca.finance.yahoo.com/quote/ETH-CAD/ | grep -Po '(currency\W{3}CAD\W{3}regularMarketPrice\W{4}raw\W{2})([\d\.]+)(\W{2}fmt)' | cut -d":" -f 4 | cut -d"," -f 1 | tail -1 | sed 's/^/ETH /'
- curl -s https://ca.finance.yahoo.com/quote/ADA-CAD/ | grep -Po '(currency\W{3}CAD\W{3}regularMarketPrice\W{4}raw\W{2})([\d\.]+)(\W{2}fmt)' | cut -d":" -f 4 | cut -d"," -f 1 | tail -1 | sed 's/^/ADA /'
- curl -s https://ca.finance.yahoo.com/quote/DOGE-CAD/ | grep -Po '(currency\W{3}CAD\W{3}regularMarketPrice\W{4}raw\W{2})([\d\.]+)(\W{2}fmt)' | cut -d":" -f 4 | cut -d"," -f 1 | tail -1 | sed 's/^/DOGE /'
- curl -s https://ca.finance.yahoo.com/quote/XMR-CAD/ | grep -Po '(currency\W{3}CAD\W{3}regularMarketPrice\W{4}raw\W{2})([\d\.]+)(\W{2}fmt)' | cut -d":" -f 4 | cut -d"," -f 1 | tail -1 | sed 's/^/XMR /'
- ~$ cat bin/wallets
- #!/bin/sh
- # Update the current pricing; don't use file if there are errors
- quotes > /tmp/quotes.dl && cp /tmp/quotes.dl /tmp/quotes.txt
- # This script is to be a cronjob; the display execution will be queued by `agenda`
- ~$ cat bin/wallets.R
- suppressMessages(library(tibble))
- suppressMessages(library(dplyr))
- suppressMessages(library(readr))
- suppressMessages(library(magrittr))
- #suppressWarnings()
- #suppressMessages()
- suppressMessages(quotes <- read_tsv('/tmp/quotes.txt', col_names = c("Asset", "Now")))
- suppressMessages(balances <- read_tsv('/home/joel/bin/balances.txt', col_names = c("Asset", "Balance", "Then", "Wallet", "Seq")))
- wallets <- balances %>% inner_join(quotes, by = 'Asset') %>% mutate(Value = Now * Balance) %>% mutate(Diff = (Now - Then) * Balance)
- summary <- select(wallets, Asset, Balance, Value, Diff) %>% group_by(Asset) %>%
- summarise(Balance = sum(Balance), Value = scales::dollar(sum(Value)), Diff = scales::dollar(sum(Diff))) %>% arrange(desc(Value))
- print(summary)
- ~$ cat bin/balances.txt
- BTC 0.01234567 45073 Live 1
- BTC 0.00123456 45037 Cold 1
- ETH 0.12345678 1614 Live 1
- ADA 23.456789 2.13 Live 1
- ADA 12.345678 2.10 Live 2
- XMR 0.12345678 499.32 Live 1
- DOGE 12.34 0.6647 Live 1
- ~$ cat /tmp/quotes.txt
- BTC 45660.125
- ETH 3292.012
- ADA 2.0895991
- DOGE 0.45860082
- XMR 360.37152
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement